pax is an archiving utility created by POSIX and defined by the POSIX.1-2001 standard. Rather than sort out the incompatible options that have crept up between tar and cpio, along with their implementations across various versions of UNIX, the IEEE designed a new archive utility that could support various archive formats, including a new format which is basically tar with additional extended attributes. The name "pax" is an acronym for portable archive exchange. The command invocation and structure is somewhat a unification of both tar and cpio.
Contents
Modes
pax has four general modes that are invoked by a combination of the -r ("read") and -w ("write") options.
This table summarizes the modal behaviour:
Examples:
List contents of an archive:
Extract contents of an archive into the current directory:
pax -r < archive.tarCreate an archive of the current directory:
When used in the cpio style, the find command can be used to get a list of files to be archived:
Copy current directory tree to another location:
The target directory must exist beforehand!
Command invocation
pax can be either used in a similar manner as cpio or tar. The cpio syntax takes a list of files from standard input (stdin) when archiving or an already existing archive, when in listing contents or extracting files:
find . -depth -print | pax -wd > archive.tarand
pax -r < archive.tarrespectively.
It is possible to invoke these commands in a tar-like syntax as well:
pax -wf archive.tar .and
pax -rf archive.tarAnd for clarity and completeness:
Listing files from an archive:
and "copy" mode:
pax -rw . archive_dirThe -f option specifies which archive to use, instead of writing to stdout or reading from stdin. Also note the -d option when using pax together with find, this keeps pax from traversing directory trees.
Compression
Most implementations of pax use the -z (gzip) and -j (bzip2) switches for compression, this feature however, is not specified by POSIX. It is important to note that pax cannot append to compressed archives.
Example for extracting a gziped archive:
Due to the possibility to use pax in a cpio-like fashion, it is possible to use whatever compression program, as an example xz is used here:
pax -w . | xz > archive.tar.xzand listing an xz-compressed archive:
xzcat archive.tar.xz | paxFormat support
As of September 2009, the version of pax included with most Linux distributions (a derivative of an old MirBSD pax) supports the following formats, selectable via the -x option:
Notably the pax format itself is not supported by this version of pax. Other implementations, such as Heirloom pax, support further formats, including the pax file format.
Multiple volumes
pax supports archiving on multiple volumes. When the end of a volume is reached, the following message appears:
When restoring an archive from multiple media, pax asks for the next media in the same fashion, when the end of the media is reached before the end of the archive.
Standardization, reception and popularity
Despite being standardized in 2001 by IEEE, as of 2010, pax enjoys relatively little popularity or adoption.
pax is required to be present in all conformant systems by Linux Standard Base since version 3.0 (released on July 6, 2005), but so far few Linux distributions ship and install it by default. However, most distributions include pax as a separately installable package.
pax has also been present in Windows NT, where it is limited to file archives (tapes not supported). It was later moved to the Interix subsystem. It does not support archiving or restoring Win32 ACLs.
Packages handled by the Installer (OS X) often carry the bulk of their contents in an Archive.pax.gz file that may be read using the pax utility.