Using the pax Archiving Tool
Over the years, a variety of UNIX operating systems have arisen, resulting in a variety of similar but incompatible file archiving formats. Even tools that go by the same name may use slightly different storage formats on different systems. This can lead to big problems when trying to archive and retrieve data in a multiplatform environment. Fortunately, there is a solution.The pax program is a POSIX standard utility that can read and write a wide variety of archive formats. An RPM package for pax is included with Red Hat Linux. If it is not already installed, copy the pax-* RPM file from your distribution media (CD #1), or download it from a Red Hat Linux FTP site, and then use the rpm command to install it.# rpm -i pax-*
Remember you need to be logged in as root when installing software with the rpm command.Pax takes a variety of command-line options. The last parameter is usually the file or directory to archive. You may use wildcard characters such as "*" or "?" to specify multiple files or directories. The options you will use most often include the -r and -w parameters for specifying when you are reading or writing an archive. These are usually used in conjunction with the -f parameter, which is used to specify the name of the archive file.By using pax parameters in different combinations, it is possible to extract an archive, create an archive, list the contents of an archive, or even copy an entire directory hierarchy from one location to another. Table 13-8 shows a few examples of the pax command in action.
Note that by leaving off both the -r and -w options, you cause pax to simply list the contents of the archive. If you specify both the -r and -w options, then you should leave off the -f option and supply source and destination directories instead. This will cause the source directory to be completely cloned in the specified destination directory.You can use additional parameters to further modify pax's behavior. For example, you may use the -x option in conjunction with the -w option to specify the specific archive type to create, or you may use the -B option to specify the number of bytes to write to each volume of a multi-volume archive.Table 13-9 briefly describes the many optional parameters to the pax command.
As you can see, pax is a very flexible and powerful archiving tool. It can be particularly helpful in migrating data from older legacy systems to your new Linux system. When you are faced with the task of recovering archived data from an antiquated or even nonfunctioning UNIX system, the multiple file format support of pax can be a literal lifesaver.