Pax (command)
Template:Short description
{{ safesubst:#invoke:Unsubst||date=__DATE__ |$B=
Template:Ambox
}}
Template:Lowercase
{{#invoke:Infobox|infobox}}Template:Template other{{#invoke:Check for unknown parameters | check | showblankpositional=1
| unknown = Template:Main other
| preview = Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y
| AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo upright | logo size | logo title | logo_alt | logo_caption | logo_upright | logo_size | logo_title | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot upright | screenshot size | screenshot title | screenshot_alt | screenshot_upright | screenshot_size | screenshot_title | service_name | size | standard | title | ver layout | website | qid
}}Template:Main other
pax is an archiving utility available for various operating systems and defined since 1995.<ref name=POSIX>The Open Group Base Specifications Issue 6 - POSIX.1-2001 (IEEE Std 1003.1) Copyright © 2001-2004 The IEEE and The Open Group</ref> 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 pax that could support various archive formats with useful options from both archivers. The pax
command is available on Unix and Unix-like operating systems and on IBM i,<ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref> and Microsoft Windows NT<ref name="Pearce1997" /> until Windows 2000.
In 2001, IEEE defined a new pax format which is basically tar with additional extended attributes.<ref name=gnu_68>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref><ref name=gnu_33>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> The format is not supported by pax commands in most Linux distributions and in FreeBSD, but it is supported by tar commands from GNU and FreeBSD; the format is further supported by pax commands in AIX, Solaris and HP-UX.
The name "pax" is an acronym for portable archive exchange, but is also an allusion to the Latin word for "peace"; the command invocation and structure represents somewhat of a peaceful unification of both tar
and cpio
.
HistoryEdit
The first public implementation of pax was written by Mark H. Colburn in 1989. Colburn posted it to Template:Mono as Usenix/IEEE POSIX replacement for TAR and CPIO. Manual pages for pax on HP-UX, IRIX, and SCO UNIX attribute pax to Colburn.<ref>TAR versus Portability – PAX and USTAR, invisible-island.net</ref>
As early as POSIX.2 draft 10 from July 1990 covers pax command.<ref>IEEE P1003.2 Draft 11.2−September 1991 (pdf) - Shell and Utilities, princeton.edu - Draft 11 indicates changes to pax so it must have been in draft 10</ref> Furthermore, POSIX.2 and IEEE 1003.1b drafts in 1991 cover pax command, featuring cpio and ustar archive formats.
Another version of the pax program was created by Keith Muller in 1992–1993.<ref>pax, svnweb.freebsd.org</ref> The version first appeared in 4.4BSD (1995).<ref name=fbsd/> Pax command appeared in X/Open issue 4 (Single Unix Specification version 1) in 1995,<ref name=POSIX/> featuring cpio and ustar archive formats, which were also the only two formats featuring in the 1997 Single Unix Specification.
In 1997, Sun Microsystems proposed a method for adding extensions to the ustar format. This method was accepted for the POSIX.1-2001 standard as the new pax file format. The POSIX specification for the Template:Tt utility was updated to include this format.<ref name=POSIX/>
FeaturesEdit
ModesEdit
pax has four general modes that are invoked by a combination of the Template:Mono ("read") and Template:Mono ("write") options.
This table summarizes the modal behaviour:
Option | Mode | Description |
---|---|---|
(none) | "list" | shows contents of archive, does not modify or extract anything. |
Template:Tt | "read" | reads and extracts contents of an archive |
Template:Tt | "write" | creates archives or appends files to an archive |
Template:Tt | "copy" | reads and copies files and directory tree to a specified directory |
This model is similar to cpio, which has a similar set of basic operations.
ExamplesEdit
List contents of an archive: Template:Sxhl
Extract contents of an archive into the current directory: Template:Sxhl
Create an archive of the current directory: Template:Sxhl Copy current directory tree to another location: Template:Sxhl (The target directory must exist beforehand!)
Command invocationEdit
By default, pax uses the standard input/output for archive and listing operations. This can be changed with the "tar-style" option <syntaxhighlight lang="text" class="" style="" inline="1">-f</syntaxhighlight> that specifies the archive file. Pax differs from cpio by recursively considering the content of a directory; to disable this behavior, POSIX pax has an option <syntaxhighlight lang="text" class="" style="" inline="1">-d</syntaxhighlight> to disable it.
The Template:Tt command is a mish-mash of Template:Tt and Template:Tt features. Like Template:Tt, Template:Tt processes directory entries recursively, a feature that can be disabled with <syntaxhighlight lang="text" class="" style="" inline="1">-d</syntaxhighlight> for cpio-style behavior. The handling of file input/outputs is also a mix: when a list of file names is specified on the command line, they are taken as shell globs for file input or listing (tar-like); otherwise Template:Tt takes the Template:Tt-style behavior of using the standard input for a file list. Finally, Template:Tt supports reading/writing to a named archive file using tar's <syntaxhighlight lang="text" class="" style="" inline="1">-f FILE</syntaxhighlight> option.
For example, if one desires a cpio-style archiving of the current directory, Template:Tt can be used with Template:Tt just like one does using cpio: Template:Sxhl (This construct is pointless without any filters for Template:Tt, as it becomes identical to the above example.)
The command for extracting the contents for an archive is the same as Template:Tt:
Template:Sxhl
It is possible to invoke these commands in a tar
-like syntax as well:
Template:Sxhl
CompressionEdit
Most implementations of pax use the Template:Tt (gzip) and Template:Tt (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 gzipped archive:
Template:Sxhl
As in tar and cpio, pax output can be piped to another compressor/decompressor program. As an example xz is used here: Template:Sxhl and listing an xz-compressed archive as the input: Template:Sxhl
Format supportEdit
POSIX.1-2001 requires that pax command supports the archive formats cpio, ustar and pax at a minimum.
The versions of pax command that stem from the 4.4BSD implementation usually inherit the formats supported by that version, selectable via the Template:Tt option:
- cpio – The extended cpio interchange format specified in the IEEE Std 1003.2 ("POSIX.2") standard.
- bcpio – The old binary cpio format.
- sv4cpio – The System V release 4 cpio.
- sv4crc – The System V release 4 cpio with file crc checksums.
- tar – The old BSD tar format as found in BSD4.3.
- ustar (default) – The tar interchange format specified in the IEEE Std 1003.2 ("POSIX.2") standard.
The POSIX.1-2001 pax format is not supported by this BSD version of pax command. The format is not supported on most Linux distributions (whose pax command is from the MirBSD branch of MirCPIO-paxmirabilis)<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref><ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref><ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> and on FreeBSD.<ref name=fbsd>Template:Man</ref> The format is supported by pax command in AIX,<ref>pax for AIX 7.3, ibm.com</ref> Solaris<ref>pax for Solaris 11.1, docs.oracle.com</ref> and HP-UX. It is further supported by Python tarfile module,<ref>tarfile, python.org</ref> by BSD-licensed libarchive,<ref>libarchive, libarchive.org</ref><ref>libarchive(3), freebsd.org</ref> by 7-ZIP<ref>HISTORY of the 7-Zip, 7-zip.org</ref> and further by GNU tar<ref>tar manual, gnu.org</ref> and FreeBSD tar.<ref>tar, freebsd.org</ref> The Heirloom Project pax command, developed by Gunnar Ritter in 2003, supports the pax format as well as many extra formats.<ref name=hl>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>
Multiple volumesEdit
pax supports archiving on multiple volumes. When the end of a volume is reached, the following message appears: <syntaxhighlight lang="console"> $ pax -wf /dev/fd0 . ATTENTION! pax archive volume change required. /dev/fd0 ready for archive volume: 2 Load the NEXT STORAGE MEDIA (if required) and make sure it is WRITE ENABLED. Type "y" to continue, "." to quit pax, or "s" to switch to new device. If you cannot change storage media, type "s" Is the device ready and online? > </syntaxhighlight>
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 popularityEdit
Despite being standardized in 2001 by IEEE, as of 2010, pax enjoys relatively little popularity or adoption.Template:Cn This is in part because there was not any need for it from the Unix users; it was just the POSIX committee that wants to have a more consistent interface. Pax is also fairly chatty and expects user interactions when things go wrong.Template:Cn
pax is required to be present in all conformant systems by Linux Standard Base since version 3.0 (released on July 6, 2005),<ref>Release notes for LSB 3.0 Template:Webarchive note that pax was added: LSB 3.0. Commands and Utilities requires pax, but LSB 2.1.0. Commands and Utilities does not require it</ref> but so far few Linux distributions ship and install it by default. However, most distributions include pax as a separately installable package.<ref>pax, pkgs.org</ref><ref>spax, pkgs.org</ref><ref>heirloom-pax, pkgs.org</ref>
pax has also been present in Windows NT, where it is limited to file archives (tapes not supported).<ref name="Pearce1997">Template:Cite book</ref> It was later moved to the Interix subsystem. It does not support archiving or restoring Win32 ACLs.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> pax was further present in Windows 2000.<ref>Virtual x86, copy.sh</ref>
Packages handled by the Installer (macOS) often carry the bulk of their contents in an Archive.pax.gz file that may be read using the system's pax (heirloom) utility.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>
See alsoEdit
ReferencesEdit
Further readingEdit
External linksEdit
Template:Sister project Template:Sister project
- Archiving with Pax Template:Webarchive Article in FreeBSD basics on ONLamp.com Template:Webarchive, by Dru Lavigne Template:Webarchive (2002-08-22)
- Template:Man
- Template:Man
- Template:Man
- pax.1p – Linux Manual – POSIX Programmer's Manual, not actual Linux
- Template:Man
- Template:Man
- Source code
Template:Compression software Template:Unix commands Template:Windows commands Template:Archive formats