World Library  
Flag as Inappropriate
Email this Article


Filename extension .cpio
Internet media type application/x-cpio
Uniform Type Identifier (UTI) public.cpio-archive
Type of format File archiver

cpio is a general file archiver utility and its associated file format. It is primarily installed on Unix-like computer operating systems. The software utility was originally intended as a tape archiving program as part of the Programmer's Workbench (PWB/UNIX), and has been a component of virtually every Unix operating system released thereafter. Its name is derived from the phrase copy in and out, in close description of the program's use of standard input and standard output in its operation.

All variants of Unix also support other backup and archiving programs, such as tar, which has become more widely recognized.[1] The use of cpio by the RPM Package Manager, in the initramfs program of Linux kernel 2.6, and in Apple Computer's Installer (pax) make cpio an important archiving tool.

Since its original design, cpio and its archive file format have undergone several, sometimes incompatible, revisions. Most notable is the change, now an operational option, from the use of a binary format of archive file meta information to an ASCII-based representation.


  • History 1
  • Operation and archive format 2
    • Archive creation 2.1
    • Extraction 2.2
    • List 2.3
    • Copy 2.4
  • POSIX standardization 3
  • Implementations 4
  • See also 5
  • References 6
  • External links 7


cpio appeared in Version 7 Unix as part of the Programmer's Workbench project.[2]

Operation and archive format

Cpio was originally designed to store backup file archives on a tape device in a sequential, contiguous manner. Cpio does not compress any content, but resulting archives are often compressed using gzip or other external compressors.

Archive creation

When creating archives during the copy-out operation, initiated with the -o command line flag, cpio reads file and directory path names from its standard input channel and writes the resulting archive byte stream to its standard output. Cpio is therefore typically used with other utilities that generate the list of files to be archived, such as the find program.

The resulting cpio archive is a sequence of files and directories concatenated into a single archive, separated by header sections with file meta information, such as filename, inode number, ownership, permissions, and timestamps. By convention, the file name of an archive is usually given a .cpio file extension.

This example uses the find utility to generate a list of path names starting in the current directory to create an archive of the directory tree:

$ find . -depth -print | cpio -o > /path/archive.cpio


During the copy-in operation, initiated by the -i command line flag, cpio reads an archive from its standard input and recreates the archived files in the operating system's file system.

$ cpio -i -vd < archive.cpio

The -d flag tells cpio to construct directories as necessary. The -v flag lists file names as they are extracted.

Any remaining command line arguments other than the option flags are shell-like globbing-patterns; only files in the archive with matching names are copied from the archive. The following example extracts /etc/fstab from the archive:

$ cpio -i -d etc/fstab < archive.cpio


The files contained in a cpio archive may be listed with this invocation:

$ cpio -i -t < archive.cpio

List may be useful since a cpio archive may contain absolute rather than relative paths (e.g., /bin/ls vs. bin/ls).


Cpio supports a third type of operation which copies files. It is initiated with the pass option (-p). This mode combines the copy-out and copy-in steps without actually creating any file archive. In this mode, cpio reads path names on standard input like the copy-out operation, but instead of creating an archive, it recreates the directories and files at a different location in the file system, as specified by the path given as a command line argument.

This example copies the directory tree starting at the current directory to another path new-path in the file system, preserving file modes (-m), creating directories as needed (-d), replacing any existing files unconditionally (-u), while producing a progress listing on standard output (-v):

$ find . -depth -print | cpio -p -dumv new-path

POSIX standardization

The cpio utility was standardized in POSIX.1-1988, but it was omitted from POSIX.1-2001 because of its file size (and other) limitations. For example, the GNU version offers various output format options, such as "bin" (default, and obsolete) and "ustar", having a file size limitations of 2147483647 bytes (2 GB) and 8589934591 bytes (8 GB), respectively.[3]

The cpio, ustar, and pax file formats are defined by POSIX.1-2001 for the pax utility, which is currently POSIX 1003.1-2008 compliant, and so it can read and write cpio and ustar formatted archives.


Most Linux distributions provide the GNU version of cpio.[4] FreeBSD and Mac OS X use the BSD-licensed cpio provided with libarchive.[5]

See also


  1. ^ Peek, J; O'Reilly, T; Loukides, M. (1997). Unix Power Tools. O'Reilly & Associates, Inc. p. 38.13.  
  2. ^  
  3. ^ See the cpio info document, in the Options node. Also, there are other limitations: see the bsdcpio man page.
  4. ^ "Cpio".
  5. ^ "libarchive". Google Code.

External links

  • FreeBSD cpio(1) manual
  • GNU cpio manual
  • GNU cpio web site
  • TAR vs. CPIO
  • Format of CPIO Archives
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.