summaryrefslogtreecommitdiff
path: root/archivers/libarchive/files/doc/wiki/ManPageBsdcpio1.wiki
blob: 2821c9eab683677b4960665fb0de3f61b56bd5dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
CPIO(1) manual page 
== NAME == 
'''cpio''' 
- copy files to and from archives 
== SYNOPSIS == 
<br> 
'''cpio''' 
-i 
<nowiki>[</nowiki>''options''<nowiki>]</nowiki> 
<nowiki>[</nowiki>''pattern'' ...<nowiki>]</nowiki> 
<nowiki>[</nowiki>''&lt;'' archive<nowiki>]</nowiki> 
<br> 
'''cpio''' 
-o 
<nowiki>[</nowiki>''options''<nowiki>]</nowiki> 
''&lt;'' name-list 
<nowiki>[</nowiki>''>'' archive<nowiki>]</nowiki> 
<br> 
'''cpio''' 
-p 
<nowiki>[</nowiki>''options''<nowiki>]</nowiki> 
''dest-dir'' 
''&lt;'' name-list 
== DESCRIPTION == 
'''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: 
<dl> 
<dt>-i</dt><dd> 
Input. 
Read an archive from standard input (unless overridden) and extract the 
contents to disk or (if the 
-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. 
</dd><dt>-o</dt><dd> 
Output. 
Read a list of filenames from standard input and produce a new archive 
on standard output (unless overridden) containing the specified items. 
</dd><dt>-p</dt><dd> 
Pass-through. 
Read a list of filenames from standard input and copy the files to the 
specified directory. 
</dd></dl> 

== OPTIONS == 
Unless specifically stated otherwise, options are applicable in 
all operating modes. 
<dl> 
<dt>-0, --null</dt><dd> 
Read filenames separated by NUL characters instead of newlines. 
This is necessary if any of the filenames being read might contain newlines. 
</dd><dt>-A</dt><dd> 
(o mode only) 
Append to the specified archive. 
(Not yet implemented.) 
</dd><dt>-a</dt><dd> 
(o and p modes) 
Reset access times on files after they are read. 
</dd><dt>-B</dt><dd> 
(o mode only) 
Block output to records of 5120 bytes. 
</dd><dt>-C ''size''</dt><dd> 
(o mode only) 
Block output to records of 
''size'' 
bytes. 
</dd><dt>-c</dt><dd> 
(o mode only) 
Use the old POSIX portable character format. 
Equivalent to 
--format ''odc''. 
</dd><dt>-d, --make-directories</dt><dd> 
(i and p modes) 
Create directories as necessary. 
</dd><dt>-E ''file''</dt><dd> 
(i mode only) 
Read list of file name patterns from 
''file'' 
to list and extract. 
</dd><dt>-F ''file'', --file ''file''</dt><dd> 
Read archive from or write archive to 
''file''. 
</dd><dt>-f ''pattern''</dt><dd> 
(i mode only) 
Ignore files that match 
''pattern''. 
</dd><dt>-H ''format'', --format ''format''</dt><dd> 
(o mode only) 
Produce the output archive in the specified format. 
Supported formats include: 

<dl> 
<dt>''cpio''</dt><dd> 
Synonym for 
''odc''. 
</dd><dt>''newc''</dt><dd> 
The SVR4 portable cpio format. 
</dd><dt>''odc''</dt><dd> 
The old POSIX.1 portable octet-oriented cpio format. 
</dd><dt>''pax''</dt><dd> 
The POSIX.1 pax format, an extension of the ustar format. 
</dd><dt>''ustar''</dt><dd> 
The POSIX.1 tar format. 
</dd></dl> 

The default format is 
''odc''. 
See 
[[ManPageLibarchiveFormats5]] 
for more complete information about the 
formats currently supported by the underlying 
[[ManPageLibarchive3]] 
library. 
</dd><dt>-h, --help</dt><dd> 
Print usage information. 
</dd><dt>-I ''file''</dt><dd> 
Read archive from 
''file''. 
</dd><dt>-i, --extract</dt><dd> 
Input mode. 
See above for description. 
</dd><dt>--insecure</dt><dd> 
(i and p mode only) 
Disable security checks during extraction or copying. 
This allows extraction via symbolic links, absolute paths, 
and path names containing 
Sq .. 
in the name. 
</dd><dt>-J, --xz</dt><dd> 
(o mode only) 
Compress the file with xz-compatible compression before writing it. 
In input mode, this option is ignored; xz compression is recognized 
automatically on input. 
</dd><dt>-j</dt><dd> 
Synonym for 
-y. 
</dd><dt>-L</dt><dd> 
(o and p modes) 
All symbolic links will be followed. 
Normally, symbolic links are archived and copied as symbolic links. 
With this option, the target of the link will be archived or copied instead. 
</dd><dt>-l, --link</dt><dd> 
(p mode only) 
Create links from the target directory to the original files, 
instead of copying. 
</dd><dt>--lrzip</dt><dd> 
(o mode only) 
Compress the resulting archive with 
[[lrzip(1)|http://www.freebsd.org/cgi/man.cgi?query=lrzip&sektion=1]]. 
In input mode, this option is ignored. 
</dd><dt>--lz4</dt><dd> 
(o mode only) 
Compress the archive with lz4-compatible compression before writing it. 
In input mode, this option is ignored; lz4 compression is recognized 
automatically on input. 
</dd><dt>--zstd</dt><dd> 
(o mode only) 
Compress the archive with zstd-compatible compression before writing it. 
In input mode, this option is ignored; zstd compression is recognized 
automatically on input. 
</dd><dt>--lzma</dt><dd> 
(o mode only) 
Compress the file with lzma-compatible compression before writing it. 
In input mode, this option is ignored; lzma compression is recognized 
automatically on input. 
</dd><dt>--lzop</dt><dd> 
(o mode only) 
Compress the resulting archive with 
[[lzop(1)|http://www.freebsd.org/cgi/man.cgi?query=lzop&sektion=1]]. 
In input mode, this option is ignored. 
</dd><dt>--passphrase ''passphrase''</dt><dd> 
The 
''passphrase'' 
is used to extract or create an encrypted archive. 
Currently, zip is only a format that 
'''cpio''' 
can handle encrypted archives. 
You shouldn't use this option unless you realize how insecure 
use of this option is. 
</dd><dt>-m, --preserve-modification-time</dt><dd> 
(i and p modes) 
Set file modification time on created files to match 
those in the source. 
</dd><dt>-n, --numeric-uid-gid</dt><dd> 
(i mode, only with 
-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. 
</dd><dt>--no-preserve-owner</dt><dd> 
(i mode only) 
Do not attempt to restore file ownership. 
This is the default when run by non-root users. 
</dd><dt>-O ''file''</dt><dd> 
Write archive to 
''file''. 
</dd><dt>-o, --create</dt><dd> 
Output mode. 
See above for description. 
</dd><dt>-p, --pass-through</dt><dd> 
Pass-through mode. 
See above for description. 
</dd><dt>--preserve-owner</dt><dd> 
(i mode only) 
Restore file ownership. 
This is the default when run by the root user. 
</dd><dt>--quiet</dt><dd> 
Suppress unnecessary messages. 
</dd><dt>-R <nowiki>[</nowiki>user<nowiki>]</nowiki><nowiki>[</nowiki>:<nowiki>]</nowiki><nowiki>[</nowiki>group<nowiki>]</nowiki>, --owner <nowiki>[</nowiki>user<nowiki>]</nowiki><nowiki>[</nowiki>:<nowiki>]</nowiki><nowiki>[</nowiki>group<nowiki>]</nowiki></dt><dd> 
Set the owner and/or group on files in the output. 
If group is specified with no user 
(for example, 
-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.) 
</dd><dt>-r</dt><dd> 
(All modes.) 
Rename files interactively. 
For each file, a prompt is written to 
''/dev/tty'' 
containing the name of the file and a line is read from 
''/dev/tty''. 
If the line read is blank, the file is skipped. 
If the line contains a single period, the file is processed normally. 
Otherwise, the line is taken to be the new name of the file. 
</dd><dt>-t, --list</dt><dd> 
(i mode only) 
List the contents of the archive to stdout; 
do not restore the contents to disk. 
</dd><dt>-u, --unconditional</dt><dd> 
(i and p modes) 
Unconditionally overwrite existing files. 
Ordinarily, an older file will not overwrite a newer file on disk. 
</dd><dt>-V, --dot</dt><dd> 
Print a dot to stderr for each file as it is processed. 
Superseded by 
-v. 
</dd><dt>-v, --verbose</dt><dd> 
Print the name of each file to stderr as it is processed. 
With 
-t, 
provide a detailed listing of each file. 
</dd><dt>--version</dt><dd> 
Print the program version information and exit. 
</dd><dt>-y</dt><dd> 
(o mode only) 
Compress the archive with bzip2-compatible compression before writing it. 
In input mode, this option is ignored; 
bzip2 compression is recognized automatically on input. 
</dd><dt>-Z</dt><dd> 
(o mode only) 
Compress the archive with compress-compatible compression before writing it. 
In input mode, this option is ignored; 
compression is recognized automatically on input. 
</dd><dt>-z</dt><dd> 
(o mode only) 
Compress the archive with gzip-compatible compression before writing it. 
In input mode, this option is ignored; 
gzip compression is recognized automatically on input. 
</dd></dl> 
== EXIT STATUS == 
The '''cpio''' utility exits 0 on success, and &gt;0 if an error occurs. 
== ENVIRONMENT == 
The following environment variables affect the execution of 
'''cpio''': 
<dl> 
<dt>'''LANG'''</dt><dd> 
The locale to use. 
See 
[[environ(7)|http://www.freebsd.org/cgi/man.cgi?query=environ&sektion=7]] 
for more information. 
</dd><dt>'''TZ'''</dt><dd> 
The timezone to use when displaying dates. 
See 
[[environ(7)|http://www.freebsd.org/cgi/man.cgi?query=environ&sektion=7]] 
for more information. 
</dd></dl> 
== EXAMPLES == 
The 
'''cpio''' 
command is traditionally used to copy file hierarchies in conjunction 
with the 
[[find(1)|http://www.freebsd.org/cgi/man.cgi?query=find&sektion=1]] 
command. 
The first example here simply copies all files from 
''src'' 
to 
''dest'': 
```text
find src | cpio -pmud dest 
```

By carefully selecting options to the 
[[find(1)|http://www.freebsd.org/cgi/man.cgi?query=find&sektion=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: 
```text
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": 
```text
find src -mtime +2 | xargs grep -l foobar | cpio -pdmu dest 
```
== COMPATIBILITY == 
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. 
== SEE ALSO == 
[[bzip2(1)|http://www.freebsd.org/cgi/man.cgi?query=bzip2&sektion=1]], 
[[ManPageBsdtar1]], 
[[gzip(1)|http://www.freebsd.org/cgi/man.cgi?query=gzip&sektion=1]], 
[[mt(1)|http://www.freebsd.org/cgi/man.cgi?query=mt&sektion=1]], 
[[pax(1)|http://www.freebsd.org/cgi/man.cgi?query=pax&sektion=1]], 
[[ManPageLibarchive3]], 
[[ManPageCpio5]], 
[[ManPageLibarchiveFormats5]], 
[[ManPageTar5]] 
== STANDARDS == 
There is no current POSIX standard for the cpio command; it appeared 
in 
<nowiki>ISO/IEC 9945-1:1996 (``POSIX.1'')</nowiki> 
but was dropped from 
<nowiki>IEEE Std 1003.1-2001 (``POSIX.1'')</nowiki>. 

The cpio, ustar, and pax interchange file formats are defined by 
<nowiki>IEEE Std 1003.1-2001 (``POSIX.1'')</nowiki> 
for the pax command. 
== HISTORY == 
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 
[[ManPageLibarchive3]] 
library. 
== BUGS == 
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.