# phpman > man > cpio(1)

> **TLDR:** Copy files in and out of archives.
>
- Take a list of file names from `stdin` and add them onto an archive (copy-[o]ut) in cpio's binary forma:
  `echo "{{path/to/file1 path/to/file2 ...}}" | cpio {{-o|--create}} > {{archive.cpio}}`
- Copy all files and directories in a directory and add them onto an archive (copy-[o]ut), in verbose mode:
  `find {{path/to/directory}} | cpio {{-ov|--create --verbose}} > {{archive.cpio}}`
- Pick all files from an archive (copy-[i]n), generating directories where needed, in verbose mode:
  `cpio < {{archive.cpio}} {{-idv|--extract --make-directories --verbose}}`

*Source: tldr-pages*

---

[CPIO(1)](https://www.chedong.com/phpMan.php/man/CPIO/1/markdown)                                       GNU CPIO                                       [CPIO(1)](https://www.chedong.com/phpMan.php/man/CPIO/1/markdown)



## NAME
       cpio - copy files to and from archives

## SYNOPSIS
       **cpio** {**-o**|**--create**} [**-0acvABLV**] [**-C** _BYTES_] [**-H** _FORMAT_] [**-M** _MESSAGE_] [**-O** [[_USER_**@**]_HOST_**:**]_ARCHIVE_]
       [**-F** [[_USER_**@**]_HOST_**:**]_ARCHIVE_] [**--file=**[[_USER_**@**]_HOST_**:**]_ARCHIVE_]  [**--format=**_FORMAT_]  [**--message=**_MES__‐
       _SAGE_]  [**--null**]  [**--reset-access-time**]  [**--verbose**]  [**--dot**] [**--append**] [**--block-size=**_blocks_]
       [**--dereference**] [**--io-size=**_BYTES_] [**--quiet**] [**--force-local**] [**--rsh-command=**_COMMAND_]  **<**  _name-_
       _list_ [**>** _archive_]

       **cpio**  {**-i**|**--extract**}  [**-bcdfmnrtsuvBSV**]  [**-C**  _BYTES_]  [**-E**  _FILE_] [**-H** _FORMAT_] [**-M** _MESSAGE_] [**-R**
       [_USER_][**:.**][_GROUP_]]      [**-I**      [[_USER_**@**]_HOST_**:**]_ARCHIVE_]      [**-F**       [[_USER_**@**]_HOST_**:**]_ARCHIVE_]
       [**--file=**[[_USER_**@**]_HOST_**:**]_ARCHIVE_]   [**--make-directories**]  [**--nonmatching**]  [**--preserve-modifica**‐‐
       **tion-time**] [**--numeric-uid-gid**] [**--rename**] [**--list**] [**--swap-bytes**] [**--swap**] [**--dot**]  [**--uncon**‐‐
       **ditional**]  [**--verbose**]  [**--block-size=**_BLOCKS_]  [**--swap-halfwords**]  [**--io-size=**_BYTES_]  [**--pat**‐‐
       **tern-file=**_FILE_] [**--format=**_FORMAT_] [**--owner=**[_USER][_**:.**][_GROUP_]]  [**--no-preserve-owner**]  [**--mes**‐‐
       **sage=**_MESSAGE_]   [**--force-local**]   [**--no-absolute-filenames**]   [**--sparse**]  [**--only-verify-crc**]
       [**--to-stdout**] [**--quiet**] [**--rsh-command=**_COMMAND_] [_pattern_...] [**<** _archive_]

       **cpio** {**-p**|**--pass-through**} [**-0adlmuvLV**] [**-R** [_USER_][**:.**][_GROUP_]]  [**--null**]  [**--reset-access-time**]
       [**--make-directories**]   [**--link**]  [**--quiet**]  [**--preserve-modification-time]**  **[--unconditional**]
       [**--verbose**]   [**--dot**]   [**--dereference**]   [**--owner=**[_USER_][**:.**][_GROUP_]]   [**--no-preserve-owner**]
       [**--sparse**] _destination-directory_ **<** _name-list_

       **cpio** {**-?**|**--help**|**--usage**|**--version**}

## REPORTING BUGS
       Report cpio bugs to <bug-cpio@gnu.org>

       GNU cpio home page: <<http://www.gnu.org/software/cpio/>>

       General help using GNU software: <<http://www.gnu.org/gethelp/>>

       Report cpio translation bugs to <<http://translationproject.org/team/>>

## SEE ALSO
       [cpio(5)](https://www.chedong.com/phpMan.php/man/cpio/5/markdown)

## DESCRIPTION
       GNU  **cpio**  copies  files between archives and directories.  It supports the following archive
       formats: old binary cpio, old portable cpio, SVR4 cpio with and without  checksum,  HP  cpio,
       and various tar formats.

       The operation mode is requested by one of the following options:

### -o --create
              Copy-out.   Read  a list of file names from the standard input and create on the stan‐
              dard output (unless overridden by the  **--file**  option)  an  archive  containing  these
              files.

### -i --extract
              Copy-in.   Read  the  archive  from standard input (or from the file supplied with the
              **--file** option) and extract files from it, or (if the **-t** option is given) list its con‐
              tents to the standard output.  If one or more _pattern_s are supplied, read or list only
              files matching these patterns.  The **-t** option alone implies **-i**.

### -p --pass-through
              Pass-through.  Read a list of file names from the standard input and copy them to  the
              specified directory.

       **-?**, **--help**
              Give a short help summary and exit.

### --usage
              Print a short usage message and exit.

### --version
              Print program version and exit.

## REPORTING BUGS
       Report cpio bugs to <bug-cpio@gnu.org>

       GNU cpio home page: <<http://www.gnu.org/software/cpio/>>

       General help using GNU software: <<http://www.gnu.org/gethelp/>>

       Report cpio translation bugs to <<http://translationproject.org/team/>>

## OPTIONS
### Operation modifiers valid in any mode
       **--block-size=**_BLOCK-SIZE_
              Set the I/O block size to _BLOCK-SIZE_ * 512 bytes.

### -B

### -c -H

### -C --io-size=
              Set the I/O block size to the given _NUMBER_ of bytes.

### -D --directory=
              Change to directory _DIR_.

### --force-local
              Archive file is local, even if its name contains colons.

### -H --format=
              Use  given archive **FORMAT**.  Valid formats are (the number in parentheses gives maximum
              size for individual archive member):

              **bin**    The obsolete binary format.  (2147483647 bytes)

              **odc**    The old (POSIX.1) portable format. (8589934591 bytes)

              **newc**   The new (SVR4) portable format, which supports file systems  having  more  than
                     65536 i-nodes. (4294967295 bytes)

              **crc**    The new (SVR4) portable format with a checksum added.

              **tar**    The old tar format. (8589934591 bytes)

              **ustar**  The  POSIX.1  tar  format.  Also recognizes GNU tar archives, which are similar
                     but not identical. (8589934591 bytes)

              **hpbin**  The obsolete binary format used by HPUX's cpio (which stores device files  dif‐
                     ferently).

              **hpodc**  The  portable  format  used  by  HPUX's cpio (which stores device files differ‐
                     ently).

### -R --owner=
              In copy-in and copy-pass mode, set the ownership of all files created to the specified
              _USER_  and/or _GROUP_.  In copy-out mode, store the supplied owner information in the ar‐
              chive.

              _USER_ and _GROUP_ are first looked up in the system user and  group  databases.   If  not
              found,  **cpio**  checks if they consist of decimal digits only and, if so, treats them as
              numeric UID and GID, correspondingly.

              To avoid the lookup and ensure that arguments are treated as  numeric  values,  prefix
              them with a plus sign, e.g.: **-R** **+0:+0**.

### --quiet
              Do not print the number of blocks copied at the end of the run.

       **--rsh-command=**_COMMAND_
              Use remote _COMMAND_ instead of **rsh**.

### -v --verbose
              Verbosely list the files processed.

### -V --dot
              Print a "**.**" for each file processed.

### -W --warning=
              Controlsи  warning  display.  The _FLAG_ is one of **none**, to disable all warnings, **all** to
              enable them, **truncate**, to enable warnings about field truncation, and **no-truncate**,  to
              disable them.

              Multiple **-W** options accumulate.

### Operation modifiers valid in copy-in and copy-out modes
### -F --file=
              Use  this  _ARCHIVE-FILE_ instead of standard input (in copy-in mode) or standard output
              (in copy-out mode).  Optional _USER_ and _HOST_ specify the user and host names in case of
              a remote archive.

### -M --message=
              Print _STRING_ when the end of a volume of the backup media is reached.

### Operation modifiers valid only in copy-in mode
### -b --swap
              Swap both halfwords of words and bytes of halfwords in the data.  Equivalent to **-sS**.

### -f --nonmatching
              Only copy files that do not match any of the given patterns.

### -n --numeric-uid-gid
              In the verbose table of contents listing, show numeric UID and GID.

### -r --rename
              Interactively rename files.

### -s --swap-bytes
              Swap the bytes of each halfword in the files.

### -S --swap-halfwords
              Swap the halfwords of each word (4 bytes) in the files.

### --to-stdout
              Extract files to standard output.

### -E --pattern-file=
              Read additional patterns specifying filenames to extract or list from _FILE_.

### --only-verify-crc
              When  reading a CRC format archive, only verify the CRC's of each file in the archive,
              without actually extracting the files.

### Operation modifiers valid only in copy-out mode
### -A --append
              Append to an existing archive.

       **--device-independent**, **--reproducible**
              Create reproducible archives.  This is equivalent to **--ignore-devno** **--renumber-inodes**.

### --ignore-devno
              Store 0 in the device number field of each archive member, instead of the  actual  de‐
              vice number.

### -O
              Use  _ARCHIVE-NAME_  instead of standard output. Optional _USER_ and _HOST_ specify the user
              and host names in case of a remote archive.

              The output archive name can be  specified  wither  using  this  option,  or  using  **-F**
              (**--file**), but not both.

### --renumber-inodes
              Renumber inodes when storing them in the archive.

### Operation modifiers valid only in copy-pass mode
### -l --link
              Link files instead of copying them, when possible.

### Operation modifiers valid in copy-in and copy-out modes
### --absolute-filenames
              Do not strip file system prefix components from the file names.  This is the default.

### --no-absolute-filenames
              Create all files relative to the current directory.

### Operation modifiers valid in copy-out and copy-pass modes
### -0 --null
              Filenames in the list are delimited by null characters instead of newlines.

### -a --reset-access-time
              Reset the access times of files after reading them.

### -I
              Use  _ARCHIVE-NAME_  instead  of standard input. Optional _USER_ and _HOST_ specify the user
              and host names in case of a remote archive.

              The input archive name can  be  specified  wither  using  this  option,  or  using  **-F**
              (**--file**), but not both.

### -L --dereference
              Dereference  symbolic  links (copy the files that they point to instead of copying the
              links).

### Operation modifiers valid in copy-in and copy-pass modes
### -d --make-directories
              Create leading directories where needed.

### -m --preserve-modification-time
              Retain previous file modification times when creating files.

### --no-preserve-owner
              Do not change the ownership of the files.

### --sparse
              Write files with large blocks of zeros as sparse files.

### -u --unconditional
              Replace all files unconditionally.

## RETURN VALUE
       GNU **cpio** exits with code **0** if it was able to successfully complete the  requested  operation.
       On errors, it exits with code **2**.

## SEE ALSO
       [**tar**(1)](https://www.chedong.com/phpMan.php/man/tar/1/markdown), [**rmt**(8)](https://www.chedong.com/phpMan.php/man/rmt/8/markdown), [**mt**(1)](https://www.chedong.com/phpMan.php/man/mt/1/markdown).

## BUG REPORTS
       Report bugs to <<bug-cpio@gnu.org>>.

## COPYRIGHT
       Copyright © 2014 Free Software Foundation, Inc.
       License GPLv3+: GNU GPL version 3 or later <<http://gnu.org/licenses/gpl.html>>
       This  is free software: you are free to change and redistribute it.  There is NO WARRANTY, to
       the extent permitted by law.




CPIO                                        June 21, 2018                                    [CPIO(1)](https://www.chedong.com/phpMan.php/man/CPIO/1/markdown)
