Compressing and Archiving

‘.tar’, ‘.gz’, ‘.tar.gz’, ‘.bz2’, ‘tar.bz2’, ‘.zip’. What are these strange extensions? Mostly you ll think these are all compressed files. But its better to understand exactly what these are. And why do we need them.

According to above extensions some are for compressed and some tells that they are archived.


In linux/unix environment there are 2 main compression algorithms. They are ‘gzip’ and ‘bzip’. The difference of ‘bzip’ from ‘gzip’ is that ‘bzip’ is more capable of making smaller files than ‘gzip’. But ‘bzip’ consumes much more memory and takes time.

Howto bzip:

as usual open up your favorite terminal/konsole :D . Then follow the commands. I m having 4 files inside /home/dushi/test directory.



now im gona compress file1.txt using bzip2.



Thats all. Now ‘file1.txt’ is replaced by ‘file1.txt.bz2’ :D

Lets decompress that newly compressed file back to ‘file1.txt’.

bzip2 -d

bzip2 -d

it will decompress the ‘.bz2’ file into its originals.

Howto gzip:



same as above its really simple. I’m gona compress ‘file2.txt’ using ‘gzip’. it gives ‘file2.txt.gz’.

gzip -d

gzip -d

use -d to decompress.


The ‘.tar’ format is the most common archive format in linux/unix environment. They are mostly called as tarballs. Archives are not compressed files. It combines one or more files into a single file. The idea is to achieve easier storage and transportation. Specially in web.

Howto archive:

lets go back into my /home/dushi/test/ directory again.



There are 4 files. Two compressed files and two normal text files. Lets archive them all into ‘MyArchive.tar’ .

tar -cf

tar -cf

from about cmd makes a tarball as ‘MyArchive.tar’ :D . To extract files from it ,

tar -xf

tar -xf

Thats all u should know :)  for more options refer,

$man tar

$man gzip


One Response to “Compressing and Archiving”

  1. Mahesh Arandara Says:

    thanks man….this was really help full.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: