Handling (Tar/GZip) and (Tar/Bzip2) archives

On August 24, 2009, in Bzip2, GZip, Tar, by Dipin Krishna

(Tar/GZip) archives end in “.tar.gz” and (Tar/Bzip2) archives end in “.tar.bz2”. Bzip2 is the newer, more efficient compression method. These files can generally be automatically extracted by merely clicking on them from your file manager (Nautilus), since file associations with the appropriate archival utilities are set by default in Ubuntu. These instructions are for those who wish to use the command line Terminal.

  • To extract:
tar xvf packagename.tar.gz

Note: tar is an application which can extract files from an archive, decompressing if necessary.

-x means extract.
-v means verbose (list what it is extracting).
-f specifies the file to use.
  • Decompressing “.gz” files
gunzip file.gz

  • Decompressing “.bz2” files
bunzip2 file.bz2

Note: You can also decompress a package first by using the command gunzip (for .gz) or bunzip2 (for .bz2), leaving the .tar file. You would then use tar to extract it.
  • To create a .gz archive:
tar cvfz packagename.tar.gz folder

  • To create a .bz2 archive:
tar cvfj packagename.tar.bz2 folder

Leave a Reply