Linux "cpio" Command Line Options and Examples
copy files to and from archives

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.


Usage:

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=MESSAGE] [--null] [--reset-access-time] [--verbose] [--dot] [--append]
[--block-size=blocks] [--dereference] [--io-size=BYTES] [--quiet] [--force-local] [--rsh-command=COMMAND] < name-list [> archive]






Command Line Options:

--block-size
Set the I/O block size to BLOCK-SIZE * 512 bytes.
cpio --block-size ...
-B
Set the I/O block size to 5120 bytes.
cpio -B ...
-c
Use the old portable (ASCII) archive format. This is the same as -H odc.
cpio -c ...
-C
Set the I/O block size to the given NUMBER of bytes.
cpio -C ...
-D
Change to directory DIR.
cpio -D ...
--force-local
Archive file is local, even if its name contains colons.
cpio --force-local ...
-H
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 differently).hpodc The portable format used by HPUX's cpio (which stores device files differently).
cpio -H ...
-R
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 archive.USER and GROUP are first looked up in the system user and group databases. If not found, cpio checks if they consist of deci‐mal 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.
cpio -R ...
--quiet
Do not print the number of blocks copied at the end of the run.
cpio --quiet ...
--rsh-command
Use remote COMMAND instead of rsh.
cpio --rsh-command ...
-v
Verbosely list the files processed.
cpio -v ...
-V
Print a "." for each file processed.
cpio -V ...
-W
Controlsи warning display. The FLAG is one of none, to disable all warnings, all to enable them, truncate, to enable warningsabout field truncation, and no-truncate, to disable them.Multiple -W options accumulate.Operation modifiers valid in copy-in and copy-out modes
cpio -W ...
-F
Use this ARCHIVE-FILE instead of standard input (in copy-in mode) or standard output (in copy-out mode). Optional USER andHOST specify the user and host names in case of a remote archive.
cpio -F ...
-M
Print STRING when the end of a volume of the backup media is reached.Operation modifiers valid only in copy-in mode
cpio -M ...
-b
Swap both halfwords of words and bytes of halfwords in the data. Equivalent to -sS.
cpio -b ...
-f
Only copy files that do not match any of the given patterns.
cpio -f ...
-n
In the verbose table of contents listing, show numeric UID and GID.
cpio -n ...
-r
Interactively rename files.
cpio -r ...
-s
Swap the bytes of each halfword in the files.
cpio -s ...
-S
Swap the halfwords of each word (4 bytes) in the files.
cpio -S ...
--to-stdout
Extract files to standard output.
cpio --to-stdout ...
-E
Read additional patterns specifying filenames to extract or list from FILE.
cpio -E ...
--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
cpio --only-verify-crc ...
-A
Append to an existing archive.
cpio -A ...
--device-independent
Create reproducible archives. This is equivalent to --ignore-devno --renumber-inodes.
cpio --device-independent ...
--ignore-devno
Store 0 in the device number field of each archive member, instead of the actual device number.
cpio --ignore-devno ...
-O
Use ARCHIVE-NAME instead of standard output. Optional USER and HOST specify the user and host names in case of a remote ar‐chive.The output archive name can be specified wither using this option, or using -F (--file), but not both.
cpio -O ...
--renumber-inodes
Renumber inodes when storing them in the archive.Operation modifiers valid only in copy-pass mode
cpio --renumber-inodes ...
-l
Link files instead of copying them, when possible.Operation modifiers valid in copy-in and copy-out modes
cpio -l ...
--absolute-filenames
Do not strip file system prefix components from the file names.
cpio --absolute-filenames ...
--no-absolute-filenames
Create all files relative to the current directory.Operation modifiers valid in copy-out and copy-pass modes
cpio --no-absolute-filenames ...
-0
Filenames in the list are delimited by null characters instead of newlines.
cpio -0 ...
-a
Reset the access times of files after reading them.
cpio -a ...
-I
Use ARCHIVE-NAME instead of standard input. Optional USER and HOST specify the user and host names in case of a remote ar‐chive.The input archive name can be specified wither using this option, or using -F (--file), but not both.
cpio -I ...
-L
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
cpio -L ...
-d
Create leading directories where needed.
cpio -d ...
-m
Retain previous file modification times when creating files.
cpio -m ...
--no-preserve-owner
Do not change the ownership of the files.
cpio --no-preserve-owner ...
--sparse
Write files with large blocks of zeros as sparse files.
cpio --sparse ...
-u
Replace all files unconditionally.RETURN VALUEGNU cpio exits with code 0 if it was able to successfully complete the requested operation. On errors, it exits with code 2.
cpio -u ...