1 .\" Copyright (c) 2003-2007 Tim Kientzle
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .Dd September 16, 2014
32 .Nd copy files to and from archives
51 copies files between archives and directories.
52 This implementation can extract from tar, pax, cpio, zip, jar, ar,
53 and ISO 9660 cdrom images and can create tar, pax, cpio, ar,
58 is a mode indicator from the following list:
59 .Bl -tag -compact -width indent
62 Read an archive from standard input (unless overridden) and extract the
63 contents to disk or (if the
66 list the contents to standard output.
67 If one or more file patterns are specified, only files matching
68 one of the patterns will be extracted.
71 Read a list of filenames from standard input and produce a new archive
72 on standard output (unless overridden) containing the specified items.
75 Read a list of filenames from standard input and copy the files to the
79 Unless specifically stated otherwise, options are applicable in
81 .Bl -tag -width indent
83 Read filenames separated by NUL characters instead of newlines.
84 This is necessary if any of the filenames being read might contain newlines.
87 Append to the specified archive.
88 (Not yet implemented.)
91 Reset access times on files after they are read.
94 Block output to records of 5120 bytes.
97 Block output to records of
102 Use the old POSIX portable character format.
104 .Fl Fl format Ar odc .
105 .It Fl d , Fl Fl make-directories
107 Create directories as necessary.
110 Read list of file name patterns from
113 .It Fl F Ar file , Fl Fl file Ar file
114 Read archive from or write archive to
118 Ignore files that match
120 .It Fl H Ar format , Fl Fl format Ar format
122 Produce the output archive in the specified format.
123 Supported formats include:
125 .Bl -tag -width "iso9660" -compact
130 The SVR4 portable cpio format.
132 The old POSIX.1 portable octet-oriented cpio format.
134 The POSIX.1 pax format, an extension of the ustar format.
136 The POSIX.1 tar format.
139 The default format is
142 .Xr libarchive-formats 5
143 for more complete information about the
144 formats currently supported by the underlying
147 .It Fl h , Fl Fl help
148 Print usage information.
152 .It Fl i , Fl Fl extract
154 See above for description.
157 Disable security checks during extraction or copying.
158 This allows extraction via symbolic links, absolute paths,
159 and path names containing
164 Compress the file with xz-compatible compression before writing it.
165 In input mode, this option is ignored; xz compression is recognized
166 automatically on input.
172 All symbolic links will be followed.
173 Normally, symbolic links are archived and copied as symbolic links.
174 With this option, the target of the link will be archived or copied instead.
175 .It Fl l , Fl Fl link
177 Create links from the target directory to the original files,
181 Compress the resulting archive with
183 In input mode, this option is ignored.
186 Compress the archive with lz4-compatible compression before writing it.
187 In input mode, this option is ignored; lz4 compression is recognized
188 automatically on input.
191 Compress the archive with zstd-compatible compression before writing it.
192 In input mode, this option is ignored; zstd compression is recognized
193 automatically on input.
196 Compress the file with lzma-compatible compression before writing it.
197 In input mode, this option is ignored; lzma compression is recognized
198 automatically on input.
201 Compress the resulting archive with
203 In input mode, this option is ignored.
204 .It Fl Fl passphrase Ar passphrase
207 is used to extract or create an encrypted archive.
208 Currently, zip is only a format that
210 can handle encrypted archives.
211 You shouldn't use this option unless you realize how insecure
212 use of this option is.
213 .It Fl m , Fl Fl preserve-modification-time
215 Set file modification time on created files to match
217 .It Fl n , Fl Fl numeric-uid-gid
220 Display numeric uid and gid.
223 displays the user and group names when they are provided in the
224 archive, or looks up the user and group names in the system
226 .It Fl Fl no-preserve-owner
228 Do not attempt to restore file ownership.
229 This is the default when run by non-root users.
233 .It Fl o , Fl Fl create
235 See above for description.
236 .It Fl p , Fl Fl pass-through
238 See above for description.
239 .It Fl Fl preserve-owner
241 Restore file ownership.
242 This is the default when run by the root user.
244 Suppress unnecessary messages.
245 .It Fl R Oo user Oc Ns Oo : Oc Ns Oo group Oc , Fl Fl owner Oo user Oc Ns Oo : Oc Ns Oo group Oc
246 Set the owner and/or group on files in the output.
247 If group is specified with no user
250 then the group will be set but not the user.
251 If the user is specified with a trailing colon and no group
254 then the group will be set to the user's default group.
255 If the user is specified with no trailing colon, then
256 the user will be set but not the group.
261 modes, this option can only be used by the super-user.
262 (For compatibility, a period can be used in place of the colon.)
265 Rename files interactively.
266 For each file, a prompt is written to
268 containing the name of the file and a line is read from
270 If the line read is blank, the file is skipped.
271 If the line contains a single period, the file is processed normally.
272 Otherwise, the line is taken to be the new name of the file.
273 .It Fl t , Fl Fl list
275 List the contents of the archive to stdout;
276 do not restore the contents to disk.
277 .It Fl u , Fl Fl unconditional
279 Unconditionally overwrite existing files.
280 Ordinarily, an older file will not overwrite a newer file on disk.
282 Print a dot to stderr for each file as it is processed.
285 .It Fl v , Fl Fl verbose
286 Print the name of each file to stderr as it is processed.
289 provide a detailed listing of each file.
291 Print the program version information and exit.
294 Compress the archive with bzip2-compatible compression before writing it.
295 In input mode, this option is ignored;
296 bzip2 compression is recognized automatically on input.
299 Compress the archive with compress-compatible compression before writing it.
300 In input mode, this option is ignored;
301 compression is recognized automatically on input.
304 Compress the archive with gzip-compatible compression before writing it.
305 In input mode, this option is ignored;
306 gzip compression is recognized automatically on input.
311 The following environment variables affect the execution of
313 .Bl -tag -width ".Ev BLOCKSIZE"
318 for more information.
320 The timezone to use when displaying dates.
323 for more information.
328 command is traditionally used to copy file hierarchies in conjunction
332 The first example here simply copies all files from
336 .Dl Nm find Pa src | Nm Fl pmud Pa dest
338 By carefully selecting options to the
340 command and combining it with other standard utilities,
341 it is possible to exercise very fine control over which files are copied.
342 This next example copies files from
346 that are more than 2 days old and whose names match a particular pattern:
347 .Dl Nm find Pa src Fl mtime Ar +2 | Nm grep foo[bar] | Nm Fl pdmu Pa dest
349 This example copies files from
353 that are more than 2 days old and which contain the word
355 .Dl Nm find Pa src Fl mtime Ar +2 | Nm xargs Nm grep -l foobar | Nm Fl pdmu Pa dest
357 The mode options i, o, and p and the options
358 a, B, c, d, f, l, m, r, t, u, and v comply with SUSv2.
360 The old POSIX.1 standard specified that only
365 were interpreted as command-line options.
366 Each took a single argument of a list of modifier
368 For example, the standard syntax allows
378 are only modifiers to
380 they are not command-line options in their own right.
381 The syntax supported by this implementation is backwards-compatible
383 For best compatibility, scripts should limit themselves to the
393 .Xr libarchive-formats 5 ,
396 There is no current POSIX standard for the cpio command; it appeared
402 The cpio, ustar, and pax interchange file formats are defined by
410 utilities were written by Dick Haight
411 while working in AT&T's Unix Support Group.
412 They first appeared in 1977 in PWB/UNIX 1.0, the
413 .Dq Programmer's Work Bench
414 system developed for use within AT&T.
415 They were first released outside of AT&T as part of System III Unix in 1981.
420 even though it was not well-known outside of AT&T until some time later.
422 This is a complete re-implementation based on the
426 The cpio archive format has several basic limitations:
427 It does not store user and group names, only numbers.
428 As a result, it cannot be reliably used to transfer
429 files between systems with dissimilar user and group numbering.
430 Older cpio formats limit the user and group numbers to
431 16 or 18 bits, which is insufficient for modern systems.
432 The cpio archive formats cannot support files over 4 gigabytes,
435 variant, which can support files up to 8 gigabytes.