1BSDCPIO(1)                BSD General Commands Manual               BSDCPIO(1)
2

NAME

4     bsdcpio — copy files to and from archives
5

SYNOPSIS

7     bsdcpio -i [options] [pattern ...] [< archive]
8     bsdcpio -o [options] < name-list [> archive]
9     bsdcpio -p [options] dest-dir < name-list
10

DESCRIPTION

12     bsdcpio copies files between archives and directories.  This implementa‐
13     tion can extract from tar, pax, cpio, zip, jar, ar, and ISO 9660 cdrom
14     images and can create tar, pax, cpio, ar, and shar archives.
15
16     The first option to bsdcpio is a mode indicator from the following list:
17     -i      Input.  Read an archive from standard input (unless overridden)
18             and extract the contents to disk or (if the -t option is speci‐
19             fied) list the contents to standard output.  If one or more file
20             patterns are specified, only files matching one of the patterns
21             will be extracted.
22     -o      Output.  Read a list of filenames from standard input and produce
23             a new archive on standard output (unless overridden) containing
24             the specified items.
25     -p      Pass-through.  Read a list of filenames from standard input and
26             copy the files to the specified directory.
27

OPTIONS

29     Unless specifically stated otherwise, options are applicable in all oper‐
30     ating modes.
31
32     -0, --null
33             Read filenames separated by NUL characters instead of newlines.
34             This is necessary if any of the filenames being read might con‐
35             tain newlines.
36
37     -6, --pwb
38             When reading a binary format archive, assume it's the earlier
39             one, from the PWB variant of 6th Edition UNIX.  When writing a
40             cpio archive, use the PWB format.
41
42     -7, --binary
43             (o mode only) When writing a cpio archive, use the (newer, non-
44             PWB) binary format.
45
46     -A      (o mode only) Append to the specified archive.  (Not yet imple‐
47             mented.)
48
49     -a      (o and p modes) Reset access times on files after they are read.
50
51     -B      (o mode only) Block output to records of 5120 bytes.
52
53     -C size
54             (o mode only) Block output to records of size bytes.
55
56     -c      (o mode only) Use the old POSIX portable character format.
57             Equivalent to --format odc.
58
59     -d, --make-directories
60             (i and p modes) Create directories as necessary.
61
62     -E file
63             (i mode only) Read list of file name patterns from file to list
64             and extract.
65
66     -F file, --file file
67             Read archive from or write archive to file.
68
69     -f pattern
70             (i mode only) Ignore files that match pattern.
71
72     -H format, --format format
73             (o mode only) Produce the output archive in the specified format.
74             Supported formats include:
75
76             cpio     Synonym for odc.
77             newc     The SVR4 portable cpio format.
78             odc      The old POSIX.1 portable octet-oriented cpio format.
79             pax      The POSIX.1 pax format, an extension of the ustar for‐
80                      mat.
81             ustar    The POSIX.1 tar format.
82
83             The default format is odc.  See libarchive-formats(5) for more
84             complete information about the formats currently supported by the
85             underlying libarchive(3) library.
86
87     -h, --help
88             Print usage information.
89
90     -I file
91             Read archive from file.
92
93     -i, --extract
94             Input mode.  See above for description.
95
96     --insecure
97             (i and p mode only) Disable security checks during extraction or
98             copying.  This allows extraction via symbolic links, absolute
99             paths, and path names containing ‘..’ in the name.
100
101     -J, --xz
102             (o mode only) Compress the file with xz-compatible compression
103             before writing it.  In input mode, this option is ignored; xz
104             compression is recognized automatically on input.
105
106     -j      Synonym for -y.
107
108     -L      (o and p modes) All symbolic links will be followed.  Normally,
109             symbolic links are archived and copied as symbolic links.  With
110             this option, the target of the link will be archived or copied
111             instead.
112
113     -l, --link
114             (p mode only) Create links from the target directory to the orig‐
115             inal files, instead of copying.
116
117     --lrzip
118             (o mode only) Compress the resulting archive with lrzip(1).  In
119             input mode, this option is ignored.
120
121     --lz4   (o mode only) Compress the archive with lz4-compatible compres‐
122             sion before writing it.  In input mode, this option is ignored;
123             lz4 compression is recognized automatically on input.
124
125     --zstd  (o mode only) Compress the archive with zstd-compatible compres‐
126             sion before writing it.  In input mode, this option is ignored;
127             zstd compression is recognized automatically on input.
128
129     --lzma  (o mode only) Compress the file with lzma-compatible compression
130             before writing it.  In input mode, this option is ignored; lzma
131             compression is recognized automatically on input.
132
133     --lzop  (o mode only) Compress the resulting archive with lzop(1).  In
134             input mode, this option is ignored.
135
136     --passphrase passphrase
137             The passphrase is used to extract or create an encrypted archive.
138             Currently, zip is only a format that bsdcpio can handle encrypted
139             archives.  You shouldn't use this option unless you realize how
140             insecure use of this option is.
141
142     -m, --preserve-modification-time
143             (i and p modes) Set file modification time on created files to
144             match those in the source.
145
146     -n, --numeric-uid-gid
147             (i mode, only with -t) Display numeric uid and gid.  By default,
148             bsdcpio displays the user and group names when they are provided
149             in the archive, or looks up the user and group names in the sys‐
150             tem password database.
151
152     --no-preserve-owner
153             (i mode only) Do not attempt to restore file ownership.  This is
154             the default when run by non-root users.
155
156     -O file
157             Write archive to file.
158
159     -o, --create
160             Output mode.  See above for description.
161
162     -p, --pass-through
163             Pass-through mode.  See above for description.
164
165     --preserve-owner
166             (i mode only) Restore file ownership.  This is the default when
167             run by the root user.
168
169     --quiet
170             Suppress unnecessary messages.
171
172     -R [user][:][group], --owner [user][:][group]
173             Set the owner and/or group on files in the output.  If group is
174             specified with no user (for example, -R :wheel) then the group
175             will be set but not the user.  If the user is specified with a
176             trailing colon and no group (for example, -R root:) then the
177             group will be set to the user's default group.  If the user is
178             specified with no trailing colon, then the user will be set but
179             not the group.  In -i and -p modes, this option can only be used
180             by the super-user.  (For compatibility, a period can be used in
181             place of the colon.)
182
183     -r      (All modes.)  Rename files interactively.  For each file, a
184             prompt is written to /dev/tty containing the name of the file and
185             a line is read from /dev/tty.  If the line read is blank, the
186             file is skipped.  If the line contains a single period, the file
187             is processed normally.  Otherwise, the line is taken to be the
188             new name of the file.
189
190     -t, --list
191             (i mode only) List the contents of the archive to stdout; do not
192             restore the contents to disk.
193
194     -u, --unconditional
195             (i and p modes) Unconditionally overwrite existing files.  Ordi‐
196             narily, an older file will not overwrite a newer file on disk.
197
198     -V, --dot
199             Print a dot to stderr for each file as it is processed.  Super‐
200             seded by -v.
201
202     -v, --verbose
203             Print the name of each file to stderr as it is processed.  With
204             -t, provide a detailed listing of each file.
205
206     --version
207             Print the program version information and exit.
208
209     -y      (o mode only) Compress the archive with bzip2-compatible compres‐
210             sion before writing it.  In input mode, this option is ignored;
211             bzip2 compression is recognized automatically on input.
212
213     -Z      (o mode only) Compress the archive with compress-compatible com‐
214             pression before writing it.  In input mode, this option is ig‐
215             nored; compression is recognized automatically on input.
216
217     -z      (o mode only) Compress the archive with gzip-compatible compres‐
218             sion before writing it.  In input mode, this option is ignored;
219             gzip compression is recognized automatically on input.
220

EXIT STATUS

222     The bsdcpio utility exits 0 on success, and >0 if an error occurs.
223

ENVIRONMENT

225     The following environment variables affect the execution of bsdcpio:
226
227     LANG       The locale to use.  See environ(7) for more information.
228
229     TZ         The timezone to use when displaying dates.  See environ(7) for
230                more information.
231

EXAMPLES

233     The bsdcpio command is traditionally used to copy file hierarchies in
234     conjunction with the find(1) command.  The first example here simply
235     copies all files from src to dest:
236           find src | bsdcpio -pmud dest
237
238     By carefully selecting options to the find(1) command and combining it
239     with other standard utilities, it is possible to exercise very fine con‐
240     trol over which files are copied.  This next example copies files from
241     src to dest that are more than 2 days old and whose names match a partic‐
242     ular pattern:
243           find src -mtime +2 | grep foo[bar] | bsdcpio -pdmu dest
244
245     This example copies files from src to dest that are more than 2 days old
246     and which contain the word “foobar”:
247           find src -mtime +2 | xargs grep -l foobar | bsdcpio -pdmu dest
248

COMPATIBILITY

250     The mode options i, o, and p and the options a, B, c, d, f, l, m, r, t,
251     u, and v comply with SUSv2.
252
253     The old POSIX.1 standard specified that only -i, -o, and -p were inter‐
254     preted as command-line options.  Each took a single argument of a list of
255     modifier characters.  For example, the standard syntax allows -imu but
256     does not support -miu or -i -m -u, since m and u are only modifiers to
257     -i, they are not command-line options in their own right.  The syntax
258     supported by this implementation is backwards-compatible with the stan‐
259     dard.  For best compatibility, scripts should limit themselves to the
260     standard syntax.
261

SEE ALSO

263     bzip2(1), gzip(1), mt(1), pax(1), tar(1), libarchive(3), cpio(5),
264     libarchive-formats(5), tar(5)
265

STANDARDS

267     There is no current POSIX standard for the cpio command; it appeared in
268     ISO/IEC 9945-1:1996 (“POSIX.1”) but was dropped from IEEE Std 1003.1-2001
269     (“POSIX.1”).
270
271     The cpio, ustar, and pax interchange file formats are defined by IEEE Std
272     1003.1-2001 (“POSIX.1”) for the pax command.
273

HISTORY

275     The original cpio and find utilities were written by Dick Haight while
276     working in AT&T's Unix Support Group.  They first appeared in 1977 in
277     PWB/UNIX 1.0, the “Programmer's Work Bench” system developed for use
278     within AT&T.  They were first released outside of AT&T as part of System
279     III Unix in 1981.  As a result, cpio actually predates tar, even though
280     it was not well-known outside of AT&T until some time later.
281
282     This is a complete re-implementation based on the libarchive(3) library.
283

BUGS

285     The cpio archive format has several basic limitations: It does not store
286     user and group names, only numbers.  As a result, it cannot be reliably
287     used to transfer files between systems with dissimilar user and group
288     numbering.  Older cpio formats limit the user and group numbers to 16 or
289     18 bits, which is insufficient for modern systems.  The cpio archive for‐
290     mats cannot support files over 4 gigabytes, except for the “odc” variant,
291     which can support files up to 8 gigabytes.
292
293BSD                           September 16, 2014                           BSD
Impressum