CPIO(1) | General Commands Manual | CPIO(1) |
cpio
— copy files
to and from archives
cpio |
-i [options]
[pattern ...] [<
archive] |
cpio |
-o [options]
< name-list [>
archive] |
cpio |
-p [options]
dest-dir < name-list |
cpio
copies files between archives and
directories. This implementation can extract from tar, pax, cpio, zip, jar,
ar, and ISO 9660 cdrom images and can create tar, pax, cpio, ar, and shar
archives.
The first option to cpio
is a mode
indicator from the following list:
-i
-t
option is
specified) list the contents to standard output. If one or more file
patterns are specified, only files matching one of the patterns will be
extracted.-o
-p
Unless specifically stated otherwise, options are applicable in all operating modes.
-0
,
--null
-6
,
--pwb
-7
,
--binary
-A
-a
-B
-C
size-c
--format
odc.-d
,
--make-directories
-E
file-F
file, --file
file-f
pattern-H
format, --format
formatThe default format is odc. See libarchive-formats(5) for more complete information about the formats currently supported by the underlying libarchive(3) library.
-h
,
--help
-I
file-i
,
--extract
--insecure
-J
,
--xz
-j
-y
.-L
-l
,
--link
--lrzip
--lz4
--zstd
--lzma
--lzop
--passphrase
passphrasecpio
can handle encrypted archives. You shouldn't
use this option unless you realize how insecure use of this option
is.-m
,
--preserve-modification-time
-n
,
--numeric-uid-gid
-t
) Display numeric uid and
gid. By default, cpio
displays the user and group
names when they are provided in the archive, or looks up the user and
group names in the system password database.--no-preserve-owner
-O
file-o
,
--create
-p
,
--pass-through
--preserve-owner
--quiet
-R
[user][:][group], --owner
[user][:][group]-R
:wheel) then the group will be set but not the user.
If the user is specified with a trailing colon and no group (for example,
-R
root:) then the group
will be set to the user's default group. If the user is specified with no
trailing colon, then the user will be set but not the group. In
-i
and -p
modes, this
option can only be used by the super-user. (For compatibility, a period
can be used in place of the colon.)-r
-t
,
--list
-u
,
--unconditional
-V
,
--dot
-v
.-v
,
--verbose
-t
, provide a detailed listing of each file.--version
-y
-Z
-z
The cpio
utility exits 0 on
success, and >0 if an error occurs.
The following environment variables affect the execution of
cpio
:
LANG
TZ
The cpio
command is traditionally used to
copy file hierarchies in conjunction with the
find(1) command. The first example here
simply copies all files from src to
dest:
find
src | cpio
-pmud
dest
By carefully selecting options to the find(1) command and combining it with other standard utilities, it is possible to exercise very fine control over which files are copied. This next example copies files from src to dest that are more than 2 days old and whose names match a particular pattern:
find
src -mtime
+2 | grep foo[bar]
|
cpio
-pdmu
dest
This example copies files from src to dest that are more than 2 days old and which contain the word “foobar”:
find
src -mtime
+2 | xargs
grep
-l foobar
| cpio
-pdmu
dest
The mode options i, o, and p and the options a, B, c, d, f, l, m, r, t, u, and v comply with SUSv2.
The old POSIX.1 standard specified that only
-i
, -o
, and
-p
were interpreted as command-line options. Each
took a single argument of a list of modifier characters. For example, the
standard syntax allows -imu
but does not support
-miu
or -i
-m
-u
, since
m and u are only modifiers to
-i
, they are not command-line options in their own
right. The syntax supported by this implementation is backwards-compatible
with the standard. For best compatibility, scripts should limit themselves
to the standard syntax.
bzip2(1), gzip(1), mt(1), pax(1), tar(1), libarchive(3), cpio(5), libarchive-formats(5), tar(5)
There is no current POSIX standard for the cpio command; it appeared in ISO/IEC 9945-1:1996 (“POSIX.1”) but was dropped from IEEE Std 1003.1-2001 (“POSIX.1”).
The cpio, ustar, and pax interchange file formats are defined by IEEE Std 1003.1-2001 (“POSIX.1”) for the pax command.
The original cpio
and
find
utilities were written by Dick Haight while
working in AT&T's Unix Support Group. They first appeared in 1977 in
PWB/UNIX 1.0, the “Programmer's Work Bench” system developed
for use within AT&T. They were first released outside of AT&T as
part of System III Unix in 1981. As a result, cpio
actually predates tar
, even though it was not
well-known outside of AT&T until some time later.
This is a complete re-implementation based on the libarchive(3) library.
The cpio archive format has several basic limitations: It does not store user and group names, only numbers. As a result, it cannot be reliably used to transfer files between systems with dissimilar user and group numbering. Older cpio formats limit the user and group numbers to 16 or 18 bits, which is insufficient for modern systems. The cpio archive formats cannot support files over 4 gigabytes, except for the “odc” variant, which can support files up to 8 gigabytes.
September 16, 2014 | x86_64 |