HOWTO tar

From LinuxNewbie

There are two common compression methods, GZip and BZip2. GZip is more common, and BZip2 provides better compression. There is more below about what the switches do and how the mechanics of the command work.
View

tar -tvf filename.tar

Uncompress: For GZip (tar.gz, tgz):

tar xzvf filename.tar.gz

For BZip2 (tar.bz2, tar.bz, tbz, tbz2):

tar xjvf filename.tar.bz2

Compress For GZip:

tar czvf filename.tar.gz /path/to/files /another/file /and/a/dir

For BZip2:

tar cjvf filename.tar.bz2 /path/to/files /another/file /and/a/dir

x extract c compress z GZip j BZip2 v verbose f filename comes next

There are two commands being run with the above commands. First tar is run; it bundles the files together but does not compress. Then GZip or BZip2 is run on the tar file to compress (make smaller). You can actually run them seperately and pipe gzip to tar as an example. If you want to see the syntax for that you can google and find examples.