Tar And Zip

Sticky 'n' Squeezed


You have a bunch of tar archive files and zipped or bzipped files to open. How?

Opening Archives

For tar.gz archive, do:

tar zxvf first-file.tar.gz

For tar.bz2 archive, do:

tar fjvx second-file.tar.bz2

If the bz2 files don't open, you don't have bzip2 installed on your box. Remedy it by running

aptitude install bzip2

Creating Archives

You have a bunch of files you want to archive using gzip or bzip2. How?

For tar.gz archive, do:

tar cfpvz third.tar.gz ~/mydir/

For tar.bz2 archive, do:

tar cfjpv fourth.tar.bz2 ~/mydir/

If you don't want to archive a directory, you can list files using linux tools such as ls or find.

  • c - creates tar archive
  • f - file archive
  • j - bzip2 compression
  • p - preserve permissions
  • v - verbose output
  • z - gzip or gunzip

Check out the man page for more options and info.

Done!