[Chapter 19] Creating and Reading Archives
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:39:20Z

#

| Chapter 19 |

# 19. Creating and Reading Archives

Contents:
Packing Up and Moving
Introduction to Shell Archives
unshar: Unarchive a Shell Archive
A Simple Version of unshar
Using tar to Create and Unpack Archives
GNU tar Sampler
Extracting Files from a Compressed Archive
Problems with Verbose tar
A System V Tape Archiver: cpio

## 19.1 Packing Up and Moving

The worst part of living in a nice big house is the headache of moving. The more stuff you've got room for, the more trouble it is to pack it up and take it with you.

The UNIX operating system is a little bit like that. One of its real advantages is a filesystem that lets you organize your personal files into a hierarchical directory tree just like the much bigger tree that encompasses the entire filesystem. You can squirrel away all kinds of useful information into neat pigeonholes.

While your personal directory hierarchy is usually only two or three levels deep, for all practical purposes it can have as many levels as you like. And, as is true of any powerful and flexible tool, problems lie in wait for the sorcerer's apprentice. Directories and files grow increasingly complex the longer you use the system, with more forgotten files and more detailed organization.

This chapter will tackle the problems that can arise when you want to move a block of files (in one or many directories) from one place to another.

Maybe you're writing the files to a tape for safety (20.2). In many cases though, this is a "backup and restore" problem. For example, if you were moving your account to another system, you might just ask the system administrator (if there is one) to archive your files to tape or floppy and restore them in the new location. Many new users are less aware that you can use the backup programs tar (20.1) and cpio (19.9) (as well as some common archive programs like shar (19.2)) to create online archives that you can move from one place to another.

This situation is most likely to arise in a networked environment. You might be packaging files to ship as a package to another user. The files might be going to Usenet or an archive site on the Internet, for distribution to many users. Even though we've made a conscious decision (1.32) to omit networking information from this book these programs are so useful even on a single system (let alone one without the artificial boundaries we've put on this book) that we decided we ought to keep this chapter in the book.

- TOR

18.16 Copying Directory Trees with (tar | tar) |  | 19.2 Introduction to Shell Archives