Friday 28 August 2009

Handling .tar.gz and .tar.bz2 files in ubuntu 9.04

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

(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:
aryan@aryan-laptop:~$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
aryan@aryan-laptop:~$gunzip file.gz
  • Decompressing ".bz2" files
aryan@aryan-laptop:~$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:
aryan@aryan-laptop:~$tar cvfz packagename.tar.gz folder
  • To create a .bz2 archive:
aryan@aryan-laptop:~$tar cvfj packagename.tar.bz2 folder

No comments:

Post a Comment