Saturday, November 21, 2009

How to TAR/UNTAR

TAR is used to create a Tape ARchive (tarball). It's pretty much the same concept as a ZIP/RAR file.

To get the files out of a tarball, *.tar :
tar xvf filename.tar
If the tarball has also been gzipped (compressed), *.tar.gz :
tar xvfz filename.tar.gz
Extract only certain directories from the tarball, do this:
tar xvzf filenameg.tar.gz */wanted.dir/*
For file *.tar.bz2, use the following command :
tar yxf filename.tar.bz2
To tar up a file in the current directory into a tarball called filename.tar.gz :
tar cfz filename.tar.gz *.db
To see a list of the files within a tarball :
tar -tzf filename.tar.gz