Everything about zip,gzip,bzip2 – Archive & Compression

Archive & Compression

$Archive :

Basically it means you take 10 files and combine them into one file.

Archive does not reduce the size of files when its combined.

For eg if you have 10 files with 100kb per size after archiving these 10 files size of single combined file is 1000kb.

So compression and archive are totally different things.

Types of Archive 

  • zip
  • gzip
  • bzip2



Zip is a compress tool which is available in most of the operating systems such as Linux/Unix, Apple OS, Microsoft OS etc. In this post we will see how to install, use and tips about zip command.

Syntax :  zip             

Ex : zip  linux.zip  file1 file2 file3 file4


zip  linux.zip  *  [ * means all files in current directory ]

Zip has a feature to provide speed for compression process below are some points which would help you to understand zip compression process clearly.

To regulate the speed of compression using value from 0  to  9 :

  • 0 indicates no compression just store or archive files.
  • 1 indicates fastest compression speed but less compression.
  • 9 indicatest slowest compression speed but more compression.
  • 6 is the default compression speed.

Let see the example for speed compression feature of zip command,

Ex 1 :-  zip -0 fun  *.docx    [ all docx files from directory ]

Above eg. we have using compression speed of 0 it means it only helps to store files as it is in .zip file. No compression is performed. we used this when we don't want to loose quality of data but just want to keep files  together.
Ex 2 :-  zip -1 fun *.doc


In second ex. we have using compression speed of 1 which means it will help to compress large no. of files in faster way but the actual data compression is less.
Ex 3 :- zip  -9  test  *.docx  *.doc


Ex. three, we have using compression speed 9 which is actually help to compress data but takes time for compression process.
Note : You have see the difference between above two ex. 2 and 3 . when speed is 1 it reduce less size but time for   compression is faster ( see doc file size) but when speed is 9 it compression is good than 1.
By default zip comression speed is 6 which is neutral in speed and compression process.

Uncompress Command

To uncompress file we are using  very simple command i.e. unzip.
Ex. unzip test.zip


Designed as open source replacement for older Unix program compress.

Safe choice to sending files to other users.

Extension of file is  '.gz'. 

Gzip  uses  the  Lempel-Ziv  algorithm used in zip and PKZIP.

Ex :  gzip  Timesheet.ods.gz Timesheet.ods

  &   gzip Timesheet.odt.gz Timesheet.odt
Ex :- gzip -c gzip.txt  >  gzip.txt.gz  [ you can use another name also with .gz extension ]


Above screenshot shows it will create .gz file of gzip.txt file and also keep your original file.

  • c  : Write  output on standard output; keep original files unchanged.
  • This option will help you to create a .gz file without prompt  and keep original file also with original name.

Extract .gz File

To extract the gzip file use below command,

Ex.  gunzip   test.gz



Sometime we have file with .gz compression and  we want to read content of that file without extracting gz file so in this situation Zcat command would read the file content without extracting and also used for extract purpose.

Ex. zcat  test1.gz  [ read contents of file ]




Bzip is more powerful compression and faster compression command than gzip.
Designed to supersede gzip, bzip2 creates smaller files but at the cost of speed.
bzip2 and bunzip2 will by default not overwrite existing files.  If you want this to happen specify the -f flag.
If  no  file names are specified, bzip2 compresses from standard input to standard output
Ex :-  bzip2 Timesheet.odt
    bzip2 -c Timesheet.odt  >  time.bz2



To Extract the bzip2 file using,

Ex. bunzip  Timesheet.odt.bz2
    bzip2 -d   time.bz2




bzcat also work like zcat used to extract or to read the contents of file,

Ex.  bzcat  time.bz2


I hope this archive and compression tutorial help you to more understand about the compression commands and where these commands are more useful. If you have any kind of questions feel free to revert on this post i will surely help you with solutions.

Leave a Reply

Your email address will not be published. Required fields are marked *