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