4 - copy files to and from archives
9 <nowiki>[</nowiki>''options''<nowiki>]</nowiki>
10 <nowiki>[</nowiki>''pattern'' ...<nowiki>]</nowiki>
11 <nowiki>[</nowiki>''<'' archive<nowiki>]</nowiki>
15 <nowiki>[</nowiki>''options''<nowiki>]</nowiki>
17 <nowiki>[</nowiki>''>'' archive<nowiki>]</nowiki>
21 <nowiki>[</nowiki>''options''<nowiki>]</nowiki>
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,
33 is a mode indicator from the following list:
37 Read an archive from standard input (unless overridden) and extract the
38 contents to disk or (if the
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.
46 Read a list of filenames from standard input and produce a new archive
47 on standard output (unless overridden) containing the specified items.
50 Read a list of filenames from standard input and copy the files to the
55 Unless specifically stated otherwise, options are applicable in
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.
63 Append to the specified archive.
64 (Not yet implemented.)
67 Reset access times on files after they are read.
70 Block output to records of 5120 bytes.
71 </dd><dt>-C ''size''</dt><dd>
73 Block output to records of
78 Use the old POSIX portable character format.
81 </dd><dt>-d, --make-directories</dt><dd>
83 Create directories as necessary.
84 </dd><dt>-E ''file''</dt><dd>
86 Read list of file name patterns from
89 </dd><dt>-F ''file'', --file ''file''</dt><dd>
90 Read archive from or write archive to
92 </dd><dt>-f ''pattern''</dt><dd>
94 Ignore files that match
96 </dd><dt>-H ''format'', --format ''format''</dt><dd>
98 Produce the output archive in the specified format.
99 Supported formats include:
102 <dt>''cpio''</dt><dd>
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.
115 The default format is
118 [[ManPageibarchiveormats5]]
119 for more complete information about the
120 formats currently supported by the underlying
121 [[ManPageibarchive3]]
123 </dd><dt>-h, --help</dt><dd>
124 Print usage information.
125 </dd><dt>-I ''file''</dt><dd>
128 </dd><dt>-i, --extract</dt><dd>
130 See above for description.
131 </dd><dt>--insecure</dt><dd>
133 Disable security checks during extraction or copying.
134 This allows extraction via symbolic links, absolute paths,
135 and path names containing
138 </dd><dt>-J, --xz</dt><dd>
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.
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>
153 Create links from the target directory to the original files,
155 </dd><dt>--lrzip</dt><dd>
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>
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>
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>
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>
178 is used to extract or create an encrypted archive.
179 Currently, zip is only a format that
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>
186 Set file modification time on created files to match
188 </dd><dt>-n, --numeric-uid-gid</dt><dd>
191 Display numeric uid and gid.
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
197 </dd><dt>--no-preserve-owner</dt><dd>
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>
204 </dd><dt>-o, --create</dt><dd>
206 See above for description.
207 </dd><dt>-p, --pass-through</dt><dd>
209 See above for description.
210 </dd><dt>--preserve-owner</dt><dd>
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
221 then the group will be set but not the user.
222 If the user is specified with a trailing colon and no group
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.
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.)
236 Rename files interactively.
237 For each file, a prompt is written to
239 containing the name of the file and a line is read from
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>
246 List the contents of the archive to stdout;
247 do not restore the contents to disk.
248 </dd><dt>-u, --unconditional</dt><dd>
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.
256 </dd><dt>-v, --verbose</dt><dd>
257 Print the name of each file to stderr as it is processed.
260 provide a detailed listing of each file.
261 </dd><dt>--version</dt><dd>
262 Print the program version information and exit.
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.
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.
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.
280 The '''cpio''' utility exits 0 on success, and >0 if an error occurs.
282 The following environment variables affect the execution of
285 <dt>'''LANG'''</dt><dd>
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.
293 [[environ(7)|http://www.freebsd.org/cgi/man.cgi?query=environ&sektion=7]]
294 for more information.
299 command is traditionally used to copy file hierarchies in conjunction
301 [[find(1)|http://www.freebsd.org/cgi/man.cgi?query=find&sektion=1]]
303 The first example here simply copies all files from
308 find src | cpio -pmud dest
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
319 that are more than 2 days old and whose names match a particular pattern:
321 find src -mtime +2 | grep foo[bar] | cpio -pdmu dest
324 This example copies files from
328 that are more than 2 days old and which contain the word
331 find src -mtime +2 | xargs grep -l foobar | cpio -pdmu dest
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.
337 The old POSIX.1 standard specified that only
342 were interpreted as command-line options.
343 Each took a single argument of a list of modifier
345 For example, the standard syntax allows
355 are only modifiers to
357 they are not command-line options in their own right.
358 The syntax supported by this implementation is backwards-compatible
360 For best compatibility, scripts should limit themselves to the
363 [[bzip2(1)|http://www.freebsd.org/cgi/man.cgi?query=bzip2&sektion=1]],
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]],
370 [[ManPageibarchiveormats5]],
373 There is no current POSIX standard for the cpio command; it appeared
375 <nowiki>ISO/IEC 9945-1:1996 (``POSIX.1'')</nowiki>
377 <nowiki>IEEE Std 1003.1-2001 (``POSIX.1'')</nowiki>.
379 The cpio, ustar, and pax interchange file formats are defined by
380 <nowiki>IEEE Std 1003.1-2001 (``POSIX.1'')</nowiki>
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.
397 even though it was not well-known outside of AT&T until some time later.
399 This is a complete re-implementation based on the
400 [[ManPageibarchive3]]
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,
412 variant, which can support files up to 8 gigabytes.