Gzip, Bzip, Zip & Tar


  1. Compression utilities (gzip, bzip2, zip)
  2. File rollers (the ability to represent many files as one)


  1. gzip - compresses/decompresses files
  2. gunzip - decompresses gzip files

  1. compress '1million.txt' file using gzip
          a. gzip -c 1million.txt > 1million.txt.gz

Note: gzip auto-dumps to STDOUT, by default
          b. gzip -l 1million.txt.gz - returns status information

  2. decompress '1million.txt.gz'
          a. gunzip 1million.txt.gz - dumps to file and remove the compressed version
          b. gzip -d 1million.txt.gz
          c. zcat 1million.txt.gz - dumps the contents to STDOUT


 1. compress '1million.txt' file using bzip
          a. bzip2 -c -v 1million.txt > 1million.txt.bz2

  2. decompress '1million.txt.bz2'
          a. bunzip1 1million.txt.bz2
          b. bzip2 -d 1million.txt.bz2
          c. bzcat 1million.txt.gz - dumps the contents to STDOUT


  1. compress '1million.txt' file using zip
          a. zip filename.zip path/ of the files - general usage
          b. zip 1million.txt.zip 1million.txt

Note: zip differs slight from gzip and bzip2 in that the destination file (resultant zip file) is spacified before the source.

  2. decompress '1million.txt.zip'
          a. unzip 1million.txt.zip

Tar & Gzip/Bzip2

  1. making archive '1million.txt' file using tar
          a. tar -cvf filename.tar path/ of the files - creates non-compressed archive
          b. tar -cvf 1million.txt.tar 1million.txt
Note: tar, requires a small overhead for itself in each file

          c. tar -czvf 1million.txt.tar.gz 1million.txt - creates, tar/gzip document
          d. tar -cjvf 1million.txt.tar.bz2 1million.txt - creates, tar/bzip document
          e. tar -cjvf 1million.txt.tar.bz2 1million.txt testRH6/ creates, tar/bzip2 document for the text file and 'testRH6' directory tree
          f. tar -rjvf 1million.txt.tar.bz2 document/ appends, tar/bzip2 document
to display the content.
          g. tar -tzvf 1million.txt.tar.gz
          h. tar -tjvf 1million.txt.tar.bz2

  2. extracting '1million.txt.tar.gz or bz or simple tar'
          a. tar -xvf 1million.txt.tar -C extracted/
          a. tar -xzvf 1million.txt.tar.gz -C extracted/
          a. tar -xjvf 1million.txt.tar.bz2 -C extracted/ - -C to create a directory

To know about the courses CLICK HERE..!!

Contact US CLICK HERE..!!


  1. Thanks for sharing such a great article! This is really very helpful for me. Best networking training in Gurgaon

  2. "Nice post. You just post the right content i was searcing for. Good Job. Linux Courses in India | Linux Server Training Institute in India training company SSDN Technologies, and become a well versed software professional.