## 38.2. tar in a Nutshell

When many Unix users think of file archives, on tape or in an archive file, they think of the tar utility. There are other ways to make archives and handle tapes -- including dump and dd. This article summarizes articles about tar in this chapter and others.

- Although tar is a tape archiver, one of its common uses is making an archive file on disk (Section 39.2). Because tar "pads" its archives with NUL characters, on-disk tar archive files can be much bigger than the size of the individual files put together. Both to fix that and generally to save space, tar files are often compressed. The GNU tar (Section 39.3) can compress files while storing them and uncompress them while reading them, automatically. If you don't have GNU tar, you may need to uncompress an archive manually. Note that a compressed tar archive can take less disk space (Section 15.7) than compressing individual small files.

  Because tar keeps most of a file's inode information, it can make a more complete copy (Section 10.13) of a file or directory tree than utilities such as cp.

- Yes, we do have articles about archives on tape. Section 38.3 has enough information to make your own archive, although you might need the details from Section 38.5, too. After you've made an archive, you'll probably want to restore it, at least as a test to be sure your archive is okay. Section 38.6 explains how.

  If there isn't a tape drive on your computer, read Section 38.7 about using a drive on another computer.

- tar copies a directory tree, recursively, from top to bottom. What if you don't want to archive everything? You can back up just some files by combining ls -lt and find. Some versions of tar have options for including or excluding certain files and directories (Section 39.3).

-- JP

Copyright © 2003 O'Reilly & Associates. All rights reserved.