UNIX Primer

Home | Primer Home

Archiving Files

Sometimes, we wish to compress our files for storage, or we wish to send many files at one time to another user. To accomplish this, we can use a utility called 'tar'. Originally written to back up important data to magnetic tape drives, 'tar' allows us to combine many files into one condensed file from which our data can later be retrieved. This is similar in some ways to 'zipping' a file, which is common under the Windows operating system.

The syntax for the 'tar' command may be difficult to understand at first, but as always, the best way to learn is to do. Try to experiment a bit with it using the syntax guide below.

Related Commands:

tar Tape ARchive To archive files (turn many into one)
tar cvf <archive filename> <file(s)>
tar xvf <archive filename> [target directory];
tar tvf <archive filename>
  • The 'c' option is for 'Compress'. This puts specified files into the archive.
  • The 'x' option is for 'eXpand'. This extracts specified files from the archive.
  • The 't' option is for 'Table of contents'. This displays the contents of the archive.
  • You may also want to familiarize yourself with the 'r' (replace) and 'u' (update) options.
  • You will generally want to use the 'v' option, which forces 'tar' to print 'verbose' messages that let you know what's going on.
  • You will always want to use the 'f' option, as this allows you to specify the archive filename that follows <options> above.
  • The slang word "tarball" is often used to refer to a tar file.
  • Files compressed with tar have the extension .tar
  • Often, tar files are also gzipped. See 'man gzip' for more information.

Designed by D. Kaminsky
Edited by Diana Palsetia
© University of Pennsylvania, 2008