WSU logo


College of Engineering & CS
Wright State University
Dayton, Ohio 45435-0001

CEG 333: Introduction to Unix

Prabhaker Mateti

tar


Tar stands for "tape archiver", although tar files are more commonly found on Internet sites than tapes nowadays. It is the most common Unix archiving utility. Unlike some compression utilities (like pkzip for .zip files), tar can only archive files (combine them into one large file) and not compress them. In keeping with the Unix philosophy of small programs that are combined as needed, separate compressors are used in conjunction with tar.

Tar can automatically call a compressor for seamless compression and decompression of archives. There are three different major Unix compressors: compress, gzip, and bzip2 Each of these works with single files. Alone, they can't combine multiple files into one package.

A tar command line gives:

For example, the tar xvvfj ~/P1-2003-Fall.tbz command given in P3 means: "Extract this is a tar file compressed with bzip2, listing every file as it's extracted."

WARNING: The file option ("-f" or just "f") uses the string immediately after it as the output filename! So tar -czfv output.tar input files will fail, because tar will write its output to a file named "v" and give an error when it doesn't find an input file named "output.tar".