Imported Upstream version 3.4.1
[platform/upstream/libarchive.git] / doc / man / bsdcpio.1
1 .TH CPIO 1 "September 16, 2014" ""
2 .SH NAME
3 .ad l
4 \fB\%cpio\fP
5 \- copy files to and from archives
6 .SH SYNOPSIS
7 .ad l
8 .br
9 \fB\%cpio\fP
10 \fB\-i\fP
11 [\fIoptions\fP]
12 [\fIpattern\fP ...]
13 [\fI<\fP archive]
14 .br
15 \fB\%cpio\fP
16 \fB\-o\fP
17 [\fIoptions\fP]
18 \fI<\fP name-list
19 [\fI>\fP archive]
20 .br
21 \fB\%cpio\fP
22 \fB\-p\fP
23 [\fIoptions\fP]
24 \fIdest-dir\fP
25 \fI<\fP name-list
26 .SH DESCRIPTION
27 .ad l
28 \fB\%cpio\fP
29 copies files between archives and directories.
30 This implementation can extract from tar, pax, cpio, zip, jar, ar,
31 and ISO 9660 cdrom images and can create tar, pax, cpio, ar,
32 and shar archives.
33 .PP
34 The first option to
35 \fB\%cpio\fP
36 is a mode indicator from the following list:
37 .RS 5
38 .TP
39 \fB\-i\fP
40 Input.
41 Read an archive from standard input (unless overridden) and extract the
42 contents to disk or (if the
43 \fB\-t\fP
44 option is specified)
45 list the contents to standard output.
46 If one or more file patterns are specified, only files matching
47 one of the patterns will be extracted.
48 .TP
49 \fB\-o\fP
50 Output.
51 Read a list of filenames from standard input and produce a new archive
52 on standard output (unless overridden) containing the specified items.
53 .TP
54 \fB\-p\fP
55 Pass-through.
56 Read a list of filenames from standard input and copy the files to the
57 specified directory.
58 .RE
59 .SH OPTIONS
60 .ad l
61 Unless specifically stated otherwise, options are applicable in
62 all operating modes.
63 .RS 5
64 .TP
65 \fB\-0\fP, \fB\-Fl\fP null
66 Read filenames separated by NUL characters instead of newlines.
67 This is necessary if any of the filenames being read might contain newlines.
68 .TP
69 \fB\-A\fP
70 (o mode only)
71 Append to the specified archive.
72 (Not yet implemented.)
73 .TP
74 \fB\-a\fP
75 (o and p modes)
76 Reset access times on files after they are read.
77 .TP
78 \fB\-B\fP
79 (o mode only)
80 Block output to records of 5120 bytes.
81 .TP
82 \fB\-C\fP \fIsize\fP
83 (o mode only)
84 Block output to records of
85 \fIsize\fP
86 bytes.
87 .TP
88 \fB\-c\fP
89 (o mode only)
90 Use the old POSIX portable character format.
91 Equivalent to
92 \fB\-Fl\fP format \fIodc\fP.
93 .TP
94 \fB\-d\fP, \fB\-Fl\fP make-directories
95 (i and p modes)
96 Create directories as necessary.
97 .TP
98 \fB\-E\fP \fIfile\fP
99 (i mode only)
100 Read list of file name patterns from
101 \fIfile\fP
102 to list and extract.
103 .TP
104 \fB\-F\fP \fIfile\fP, \fB\-Fl\fP file \fIfile\fP
105 Read archive from or write archive to
106 \fIfile\fP.
107 .TP
108 \fB\-f\fP \fIpattern\fP
109 (i mode only)
110 Ignore files that match
111 \fIpattern\fP.
112 .TP
113 \fB\-H\fP \fIformat\fP, \fB\-Fl\fP format \fIformat\fP
114 (o mode only)
115 Produce the output archive in the specified format.
116 Supported formats include:
117 .PP
118 .RS 5
119 .TP
120 \fIcpio\fP
121 Synonym for
122 \fIodc\fP.
123 .TP
124 \fInewc\fP
125 The SVR4 portable cpio format.
126 .TP
127 \fIodc\fP
128 The old POSIX.1 portable octet-oriented cpio format.
129 .TP
130 \fIpax\fP
131 The POSIX.1 pax format, an extension of the ustar format.
132 .TP
133 \fIustar\fP
134 The POSIX.1 tar format.
135 .RE
136 .PP
137 The default format is
138 \fIodc\fP.
139 See
140 \fBlibarchive-formats\fP(5)
141 for more complete information about the
142 formats currently supported by the underlying
143 \fBlibarchive\fP(3)
144 library.
145 .TP
146 \fB\-h\fP, \fB\-Fl\fP help
147 Print usage information.
148 .TP
149 \fB\-I\fP \fIfile\fP
150 Read archive from
151 \fIfile\fP.
152 .TP
153 \fB\-i\fP, \fB\-Fl\fP extract
154 Input mode.
155 See above for description.
156 .TP
157 \fB\-Fl\fP insecure
158 (i and p mode only)
159 Disable security checks during extraction or copying.
160 This allows extraction via symbolic links, absolute paths,
161 and path names containing
162 Sq ..
163 in the name.
164 .TP
165 \fB\-J\fP, \fB\-Fl\fP xz
166 (o mode only)
167 Compress the file with xz-compatible compression before writing it.
168 In input mode, this option is ignored; xz compression is recognized
169 automatically on input.
170 .TP
171 \fB\-j\fP
172 Synonym for
173 \fB\-y\fP.
174 .TP
175 \fB\-L\fP
176 (o and p modes)
177 All symbolic links will be followed.
178 Normally, symbolic links are archived and copied as symbolic links.
179 With this option, the target of the link will be archived or copied instead.
180 .TP
181 \fB\-l\fP, \fB\-Fl\fP link
182 (p mode only)
183 Create links from the target directory to the original files,
184 instead of copying.
185 .TP
186 \fB\-Fl\fP lrzip
187 (o mode only)
188 Compress the resulting archive with
189 \fBlrzip\fP(1).
190 In input mode, this option is ignored.
191 .TP
192 \fB\-Fl\fP lz4
193 (o mode only)
194 Compress the archive with lz4-compatible compression before writing it.
195 In input mode, this option is ignored; lz4 compression is recognized
196 automatically on input.
197 .TP
198 \fB\-Fl\fP zstd
199 (o mode only)
200 Compress the archive with zstd-compatible compression before writing it.
201 In input mode, this option is ignored; zstd compression is recognized
202 automatically on input.
203 .TP
204 \fB\-Fl\fP lzma
205 (o mode only)
206 Compress the file with lzma-compatible compression before writing it.
207 In input mode, this option is ignored; lzma compression is recognized
208 automatically on input.
209 .TP
210 \fB\-Fl\fP lzop
211 (o mode only)
212 Compress the resulting archive with
213 \fBlzop\fP(1).
214 In input mode, this option is ignored.
215 .TP
216 \fB\-Fl\fP passphrase \fIpassphrase\fP
217 The
218 \fIpassphrase\fP
219 is used to extract or create an encrypted archive.
220 Currently, zip is only a format that
221 \fB\%cpio\fP
222 can handle encrypted archives.
223 You shouldn't use this option unless you realize how insecure
224 use of this option is.
225 .TP
226 \fB\-m\fP, \fB\-Fl\fP preserve-modification-time
227 (i and p modes)
228 Set file modification time on created files to match
229 those in the source.
230 .TP
231 \fB\-n\fP, \fB\-Fl\fP numeric-uid-gid
232 (i mode, only with
233 \fB\-t\fP)
234 Display numeric uid and gid.
235 By default,
236 \fB\%cpio\fP
237 displays the user and group names when they are provided in the
238 archive, or looks up the user and group names in the system
239 password database.
240 .TP
241 \fB\-Fl\fP no-preserve-owner
242 (i mode only)
243 Do not attempt to restore file ownership.
244 This is the default when run by non-root users.
245 .TP
246 \fB\-O\fP \fIfile\fP
247 Write archive to
248 \fIfile\fP.
249 .TP
250 \fB\-o\fP, \fB\-Fl\fP create
251 Output mode.
252 See above for description.
253 .TP
254 \fB\-p\fP, \fB\-Fl\fP pass-through
255 Pass-through mode.
256 See above for description.
257 .TP
258 \fB\-Fl\fP preserve-owner
259 (i mode only)
260 Restore file ownership.
261 This is the default when run by the root user.
262 .TP
263 \fB\-Fl\fP quiet
264 Suppress unnecessary messages.
265 .TP
266 \fB\-R\fP [user] [:] [group], \fB\-Fl\fP owner [user] [:] [group]
267 Set the owner and/or group on files in the output.
268 If group is specified with no user
269 (for example,
270 \fB\-R\fP \fI:wheel\fP)
271 then the group will be set but not the user.
272 If the user is specified with a trailing colon and no group
273 (for example,
274 \fB\-R\fP \fIroot:\fP)
275 then the group will be set to the user's default group.
276 If the user is specified with no trailing colon, then
277 the user will be set but not the group.
278 In
279 \fB\-i\fP
280 and
281 \fB\-p\fP
282 modes, this option can only be used by the super-user.
283 (For compatibility, a period can be used in place of the colon.)
284 .TP
285 \fB\-r\fP
286 (All modes.)
287 Rename files interactively.
288 For each file, a prompt is written to
289 \fI/dev/tty\fP
290 containing the name of the file and a line is read from
291 \fI/dev/tty\fP.
292 If the line read is blank, the file is skipped.
293 If the line contains a single period, the file is processed normally.
294 Otherwise, the line is taken to be the new name of the file.
295 .TP
296 \fB\-t\fP, \fB\-Fl\fP list
297 (i mode only)
298 List the contents of the archive to stdout;
299 do not restore the contents to disk.
300 .TP
301 \fB\-u\fP, \fB\-Fl\fP unconditional
302 (i and p modes)
303 Unconditionally overwrite existing files.
304 Ordinarily, an older file will not overwrite a newer file on disk.
305 .TP
306 \fB\-V\fP, \fB\-Fl\fP dot
307 Print a dot to stderr for each file as it is processed.
308 Superseded by
309 \fB\-v\fP.
310 .TP
311 \fB\-v\fP, \fB\-Fl\fP verbose
312 Print the name of each file to stderr as it is processed.
313 With
314 \fB\-t\fP,
315 provide a detailed listing of each file.
316 .TP
317 \fB\-Fl\fP version
318 Print the program version information and exit.
319 .TP
320 \fB\-y\fP
321 (o mode only)
322 Compress the archive with bzip2-compatible compression before writing it.
323 In input mode, this option is ignored;
324 bzip2 compression is recognized automatically on input.
325 .TP
326 \fB\-Z\fP
327 (o mode only)
328 Compress the archive with compress-compatible compression before writing it.
329 In input mode, this option is ignored;
330 compression is recognized automatically on input.
331 .TP
332 \fB\-z\fP
333 (o mode only)
334 Compress the archive with gzip-compatible compression before writing it.
335 In input mode, this option is ignored;
336 gzip compression is recognized automatically on input.
337 .RE
338 .SH EXIT STATUS
339 .ad l
340 The \fBcpio\fP utility exits 0 on success, and >0 if an error occurs.
341 .SH ENVIRONMENT
342 .ad l
343 The following environment variables affect the execution of
344 \fB\%cpio\fP:
345 .RS 5
346 .TP
347 .B LANG
348 The locale to use.
349 See
350 \fBenviron\fP(7)
351 for more information.
352 .TP
353 .B TZ
354 The timezone to use when displaying dates.
355 See
356 \fBenviron\fP(7)
357 for more information.
358 .RE
359 .SH EXAMPLES
360 .ad l
361 The
362 \fB\%cpio\fP
363 command is traditionally used to copy file hierarchies in conjunction
364 with the
365 \fBfind\fP(1)
366 command.
367 The first example here simply copies all files from
368 \fIsrc\fP
369 to
370 \fIdest\fP:
371 .RS 4
372 \fB\%find\fP \fIsrc\fP | \fB\%cpio\fP \fB\-pmud\fP \fIdest\fP
373 .RE
374 .PP
375 By carefully selecting options to the
376 \fBfind\fP(1)
377 command and combining it with other standard utilities,
378 it is possible to exercise very fine control over which files are copied.
379 This next example copies files from
380 \fIsrc\fP
381 to
382 \fIdest\fP
383 that are more than 2 days old and whose names match a particular pattern:
384 .RS 4
385 \fB\%find\fP \fIsrc\fP \fB\-mtime\fP \fI+2\fP | \fB\%grep\fP foo[bar] | \fB\%cpio\fP \fB\-pdmu\fP \fIdest\fP
386 .RE
387 .PP
388 This example copies files from
389 \fIsrc\fP
390 to
391 \fIdest\fP
392 that are more than 2 days old and which contain the word
393 ``foobar'':
394 .RS 4
395 \fB\%find\fP \fIsrc\fP \fB\-mtime\fP \fI+2\fP | \fB\%xargs\fP \fB\%grep\fP -l foobar | \fB\%cpio\fP \fB\-pdmu\fP \fIdest\fP
396 .RE
397 .SH COMPATIBILITY
398 .ad l
399 The mode options i, o, and p and the options
400 a, B, c, d, f, l, m, r, t, u, and v comply with SUSv2.
401 .PP
402 The old POSIX.1 standard specified that only
403 \fB\-i\fP,
404 \fB\-o\fP,
405 and
406 \fB\-p\fP
407 were interpreted as command-line options.
408 Each took a single argument of a list of modifier
409 characters.
410 For example, the standard syntax allows
411 \fB\-imu\fP
412 but does not support
413 \fB\-miu\fP
414 or
415 \fB\-i\fP \fB\-m\fP \fB\-u\fP,
416 since
417 \fIm\fP
418 and
419 \fIu\fP
420 are only modifiers to
421 \fB\-i\fP,
422 they are not command-line options in their own right.
423 The syntax supported by this implementation is backwards-compatible
424 with the standard.
425 For best compatibility, scripts should limit themselves to the
426 standard syntax.
427 .SH SEE ALSO
428 .ad l
429 \fBbzip2\fP(1),
430 \fBgzip\fP(1),
431 \fBmt\fP(1),
432 \fBpax\fP(1),
433 \fBtar\fP(1),
434 \fBlibarchive\fP(3),
435 \fBcpio\fP(5),
436 \fBlibarchive-formats\fP(5),
437 \fBtar\fP(5)
438 .SH STANDARDS
439 .ad l
440 There is no current POSIX standard for the cpio command; it appeared
441 in
442 ISO/IEC 9945-1:1996 (``POSIX.1'')
443 but was dropped from
444 IEEE Std 1003.1-2001 (``POSIX.1'').
445 .PP
446 The cpio, ustar, and pax interchange file formats are defined by
447 IEEE Std 1003.1-2001 (``POSIX.1'')
448 for the pax command.
449 .SH HISTORY
450 .ad l
451 The original
452 \fB\%cpio\fP
453 and
454 \fB\%find\fP
455 utilities were written by Dick Haight
456 while working in AT&T's Unix Support Group.
457 They first appeared in 1977 in PWB/UNIX 1.0, the
458 ``Programmer's Work Bench''
459 system developed for use within AT&T.
460 They were first released outside of AT&T as part of System III Unix in 1981.
461 As a result,
462 \fB\%cpio\fP
463 actually predates
464 \fB\%tar\fP,
465 even though it was not well-known outside of AT&T until some time later.
466 .PP
467 This is a complete re-implementation based on the
468 \fBlibarchive\fP(3)
469 library.
470 .SH BUGS
471 .ad l
472 The cpio archive format has several basic limitations:
473 It does not store user and group names, only numbers.
474 As a result, it cannot be reliably used to transfer
475 files between systems with dissimilar user and group numbering.
476 Older cpio formats limit the user and group numbers to
477 16 or 18 bits, which is insufficient for modern systems.
478 The cpio archive formats cannot support files over 4 gigabytes,
479 except for the
480 ``odc''
481 variant, which can support files up to 8 gigabytes.