Tar is an acronym for 'Tape ARchive', and is the most common tool for collecting a bunch of files into one easily-portable package. You will use this tool on a regular basis for moving files around. The three basic things you'll do with it are:
$ tar czvf tarball.tgz file1.txt file2.c dir1/
$ tar tzvf tarball.tgz
$ tar xzvf tarball.tgz
Or, if you only want a specific file from the tarball, put the filename (including the relative path within the tarball) as an additional argument to the command.
$ tar xzvf tarball.tgz file1.txt
Keep in mind that Unix treats all devices as files. For this reason, you can tar to a device as easily as you can tar to a file. For instance, this command will tar up the contents of /home to the first SCSI tape drive:
# tar czvf /dev/st0 /home
Tar can also be used in a 'pass through' mode; whereby one uses tar to copy from one filesystem to another. This is useful in some cases, such as when you want to pass it over the network using ssh or netcat; or when you want to use the advanced include/exclude/preserve/dereference features of tar to treat the files in a particular way.
$ tar cpf - /dir/to/backup|tar xvp -C /place/you/want/to/put/that
Keep in mind that tar will remember the full path to the files; so the result of the above command will be /place/you/want/to/put/that/dir/to/backup
Watch out for corrupted tarballs!
One of the disadvantages of tar, is that if a compressed tar file becomes corrupt, all data sequentially after the corruption is lost! (Admittedly, this is not strictly a problem exclusive to tar. Compressing any file as a whole opens the possibility for this problem.) If the tar archive is uncompressed, it may be possible to recover at the next file within the archive; but this is not guaranteed (though they say it works pretty well).
The instructions and screen shots contained within this website are specific to services offered by Real Time Enterprises only.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".