xref: /minix3/external/bsd/libarchive/dist/cpio/bsdcpio.1 (revision 543adbed3a3a783ed36434adafbc258b6bde442d)
1*543adbedSBen Gras.\" Copyright (c) 2003-2007 Tim Kientzle
2*543adbedSBen Gras.\" All rights reserved.
3*543adbedSBen Gras.\"
4*543adbedSBen Gras.\" Redistribution and use in source and binary forms, with or without
5*543adbedSBen Gras.\" modification, are permitted provided that the following conditions
6*543adbedSBen Gras.\" are met:
7*543adbedSBen Gras.\" 1. Redistributions of source code must retain the above copyright
8*543adbedSBen Gras.\"    notice, this list of conditions and the following disclaimer.
9*543adbedSBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
10*543adbedSBen Gras.\"    notice, this list of conditions and the following disclaimer in the
11*543adbedSBen Gras.\"    documentation and/or other materials provided with the distribution.
12*543adbedSBen Gras.\"
13*543adbedSBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14*543adbedSBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*543adbedSBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*543adbedSBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*543adbedSBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*543adbedSBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*543adbedSBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*543adbedSBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*543adbedSBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*543adbedSBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*543adbedSBen Gras.\" SUCH DAMAGE.
24*543adbedSBen Gras.\"
25*543adbedSBen Gras.\" $FreeBSD$
26*543adbedSBen Gras.\"
27*543adbedSBen Gras.Dd December 21, 2007
28*543adbedSBen Gras.Dt BSDCPIO 1
29*543adbedSBen Gras.Os
30*543adbedSBen Gras.Sh NAME
31*543adbedSBen Gras.Nm cpio
32*543adbedSBen Gras.Nd copy files to and from archives
33*543adbedSBen Gras.Sh SYNOPSIS
34*543adbedSBen Gras.Nm
35*543adbedSBen Gras.Brq Fl i
36*543adbedSBen Gras.Op Ar options
37*543adbedSBen Gras.Op Ar pattern ...
38*543adbedSBen Gras.Op Ar < archive
39*543adbedSBen Gras.Nm
40*543adbedSBen Gras.Brq Fl o
41*543adbedSBen Gras.Op Ar options
42*543adbedSBen Gras.Ar < name-list
43*543adbedSBen Gras.Op Ar > archive
44*543adbedSBen Gras.Nm
45*543adbedSBen Gras.Brq Fl p
46*543adbedSBen Gras.Op Ar options
47*543adbedSBen Gras.Ar dest-dir
48*543adbedSBen Gras.Ar < name-list
49*543adbedSBen Gras.Sh DESCRIPTION
50*543adbedSBen Gras.Nm
51*543adbedSBen Grascopies files between archives and directories.
52*543adbedSBen GrasThis implementation can extract from tar, pax, cpio, zip, jar, ar,
53*543adbedSBen Grasand ISO 9660 cdrom images and can create tar, pax, cpio, ar,
54*543adbedSBen Grasand shar archives.
55*543adbedSBen Gras.Pp
56*543adbedSBen GrasThe first option to
57*543adbedSBen Gras.Nm
58*543adbedSBen Grasis a mode indicator from the following list:
59*543adbedSBen Gras.Bl -tag -compact -width indent
60*543adbedSBen Gras.It Fl i
61*543adbedSBen GrasInput.
62*543adbedSBen GrasRead an archive from standard input (unless overriden) and extract the
63*543adbedSBen Grascontents to disk or (if the
64*543adbedSBen Gras.Fl t
65*543adbedSBen Grasoption is specified)
66*543adbedSBen Graslist the contents to standard output.
67*543adbedSBen GrasIf one or more file patterns are specified, only files matching
68*543adbedSBen Grasone of the patterns will be extracted.
69*543adbedSBen Gras.It Fl o
70*543adbedSBen GrasOutput.
71*543adbedSBen GrasRead a list of filenames from standard input and produce a new archive
72*543adbedSBen Grason standard output (unless overriden) containing the specified items.
73*543adbedSBen Gras.It Fl p
74*543adbedSBen GrasPass-through.
75*543adbedSBen GrasRead a list of filenames from standard input and copy the files to the
76*543adbedSBen Grasspecified directory.
77*543adbedSBen Gras.El
78*543adbedSBen Gras.Pp
79*543adbedSBen Gras.Sh OPTIONS
80*543adbedSBen GrasUnless specifically stated otherwise, options are applicable in
81*543adbedSBen Grasall operating modes.
82*543adbedSBen Gras.Bl -tag -width indent
83*543adbedSBen Gras.It Fl 0
84*543adbedSBen GrasRead filenames separated by NUL characters instead of newlines.
85*543adbedSBen GrasThis is necessary if any of the filenames being read might contain newlines.
86*543adbedSBen Gras.It Fl A
87*543adbedSBen Gras(o mode only)
88*543adbedSBen GrasAppend to the specified archive.
89*543adbedSBen Gras(Not yet implemented.)
90*543adbedSBen Gras.It Fl a
91*543adbedSBen Gras(o and p modes)
92*543adbedSBen GrasReset access times on files after they are read.
93*543adbedSBen Gras.It Fl B
94*543adbedSBen Gras(o mode only)
95*543adbedSBen GrasBlock output to records of 5120 bytes.
96*543adbedSBen Gras.It Fl C Ar size
97*543adbedSBen Gras(o mode only)
98*543adbedSBen GrasBlock output to records of
99*543adbedSBen Gras.Ar size
100*543adbedSBen Grasbytes.
101*543adbedSBen Gras.It Fl c
102*543adbedSBen Gras(o mode only)
103*543adbedSBen GrasUse the old POSIX portable character format.
104*543adbedSBen GrasEquivalent to
105*543adbedSBen Gras.Fl -format Ar odc .
106*543adbedSBen Gras.It Fl d
107*543adbedSBen Gras(i and p modes)
108*543adbedSBen GrasCreate directories as necessary.
109*543adbedSBen Gras.It Fl E Ar file
110*543adbedSBen Gras(i mode only)
111*543adbedSBen GrasRead list of file name patterns from
112*543adbedSBen Gras.Ar file
113*543adbedSBen Grasto list and extract.
114*543adbedSBen Gras.It Fl F Ar file
115*543adbedSBen GrasRead archive from or write archive to
116*543adbedSBen Gras.Ar file .
117*543adbedSBen Gras.It Fl f Ar pattern
118*543adbedSBen Gras(i mode only)
119*543adbedSBen GrasIgnore files that match
120*543adbedSBen Gras.Ar pattern .
121*543adbedSBen Gras.It Fl -format Ar format
122*543adbedSBen Gras(o mode only)
123*543adbedSBen GrasProduce the output archive in the specified format.
124*543adbedSBen GrasSupported formats include:
125*543adbedSBen Gras.Pp
126*543adbedSBen Gras.Bl -tag -width "iso9660" -compact
127*543adbedSBen Gras.It Ar cpio
128*543adbedSBen GrasSynonym for
129*543adbedSBen Gras.Ar odc .
130*543adbedSBen Gras.It Ar newc
131*543adbedSBen GrasThe SVR4 portable cpio format.
132*543adbedSBen Gras.It Ar odc
133*543adbedSBen GrasThe old POSIX.1 portable octet-oriented cpio format.
134*543adbedSBen Gras.It Ar pax
135*543adbedSBen GrasThe POSIX.1 pax format, an extension of the ustar format.
136*543adbedSBen Gras.It Ar ustar
137*543adbedSBen GrasThe POSIX.1 tar format.
138*543adbedSBen Gras.El
139*543adbedSBen Gras.Pp
140*543adbedSBen GrasThe default format is
141*543adbedSBen Gras.Ar odc .
142*543adbedSBen GrasSee
143*543adbedSBen Gras.Xr libarchive_formats 5
144*543adbedSBen Grasfor more complete information about the
145*543adbedSBen Grasformats currently supported by the underlying
146*543adbedSBen Gras.Xr libarchive 3
147*543adbedSBen Graslibrary.
148*543adbedSBen Gras.It Fl H Ar format
149*543adbedSBen GrasSynonym for
150*543adbedSBen Gras.Fl -format .
151*543adbedSBen Gras.It Fl h , Fl -help
152*543adbedSBen GrasPrint usage information.
153*543adbedSBen Gras.It Fl I Ar file
154*543adbedSBen GrasRead archive from
155*543adbedSBen Gras.Ar file .
156*543adbedSBen Gras.It Fl i
157*543adbedSBen GrasInput mode.
158*543adbedSBen GrasSee above for description.
159*543adbedSBen Gras.It Fl -insecure
160*543adbedSBen Gras(i and p mode only)
161*543adbedSBen GrasDisable security checks during extraction or copying.
162*543adbedSBen GrasThis allows extraction via symbolic links and path names containing
163*543adbedSBen Gras.Sq ..
164*543adbedSBen Grasin the name.
165*543adbedSBen Gras.It Fl J
166*543adbedSBen Gras(o mode only)
167*543adbedSBen GrasCompress the file with xz-compatible compression before writing it.
168*543adbedSBen GrasIn input mode, this option is ignored; xz compression is recognized
169*543adbedSBen Grasautomatically on input.
170*543adbedSBen Gras.It Fl j
171*543adbedSBen GrasSynonym for
172*543adbedSBen Gras.Fl y .
173*543adbedSBen Gras.It Fl L
174*543adbedSBen Gras(o and p modes)
175*543adbedSBen GrasAll symbolic links will be followed.
176*543adbedSBen GrasNormally, symbolic links are archived and copied as symbolic links.
177*543adbedSBen GrasWith this option, the target of the link will be archived or copied instead.
178*543adbedSBen Gras.It Fl l
179*543adbedSBen Gras(p mode only)
180*543adbedSBen GrasCreate links from the target directory to the original files,
181*543adbedSBen Grasinstead of copying.
182*543adbedSBen Gras.It Fl lzma
183*543adbedSBen Gras(o mode only)
184*543adbedSBen GrasCompress the file with lzma-compatible compression before writing it.
185*543adbedSBen GrasIn input mode, this option is ignored; lzma compression is recognized
186*543adbedSBen Grasautomatically on input.
187*543adbedSBen Gras.It Fl m
188*543adbedSBen Gras(i and p modes)
189*543adbedSBen GrasSet file modification time on created files to match
190*543adbedSBen Grasthose in the source.
191*543adbedSBen Gras.It Fl n
192*543adbedSBen Gras(i mode, only with
193*543adbedSBen Gras.Fl t )
194*543adbedSBen GrasDisplay numeric uid and gid.
195*543adbedSBen GrasBy default,
196*543adbedSBen Gras.Nm
197*543adbedSBen Grasdisplays the user and group names when they are provided in the
198*543adbedSBen Grasarchive, or looks up the user and group names in the system
199*543adbedSBen Graspassword database.
200*543adbedSBen Gras.It Fl no-preserve-owner
201*543adbedSBen Gras(i mode only)
202*543adbedSBen GrasDo not attempt to restore file ownership.
203*543adbedSBen GrasThis is the default when run by non-root users.
204*543adbedSBen Gras.It Fl O Ar file
205*543adbedSBen GrasWrite archive to
206*543adbedSBen Gras.Ar file .
207*543adbedSBen Gras.It Fl o
208*543adbedSBen GrasOutput mode.
209*543adbedSBen GrasSee above for description.
210*543adbedSBen Gras.It Fl p
211*543adbedSBen GrasPass-through mode.
212*543adbedSBen GrasSee above for description.
213*543adbedSBen Gras.It Fl preserve-owner
214*543adbedSBen Gras(i mode only)
215*543adbedSBen GrasRestore file ownership.
216*543adbedSBen GrasThis is the default when run by the root user.
217*543adbedSBen Gras.It Fl -quiet
218*543adbedSBen GrasSuppress unnecessary messages.
219*543adbedSBen Gras.It Fl R Oo user Oc Ns Oo : Oc Ns Oo group Oc
220*543adbedSBen GrasSet the owner and/or group on files in the output.
221*543adbedSBen GrasIf group is specified with no user
222*543adbedSBen Gras(for example,
223*543adbedSBen Gras.Fl R Ar :wheel )
224*543adbedSBen Grasthen the group will be set but not the user.
225*543adbedSBen GrasIf the user is specified with a trailing colon and no group
226*543adbedSBen Gras(for example,
227*543adbedSBen Gras.Fl R Ar root: )
228*543adbedSBen Grasthen the group will be set to the user's default group.
229*543adbedSBen GrasIf the user is specified with no trailing colon, then
230*543adbedSBen Grasthe user will be set but not the group.
231*543adbedSBen GrasIn
232*543adbedSBen Gras.Fl i
233*543adbedSBen Grasand
234*543adbedSBen Gras.Fl p
235*543adbedSBen Grasmodes, this option can only be used by the super-user.
236*543adbedSBen Gras(For compatibility, a period can be used in place of the colon.)
237*543adbedSBen Gras.It Fl r
238*543adbedSBen Gras(All modes.)
239*543adbedSBen GrasRename files interactively.
240*543adbedSBen GrasFor each file, a prompt is written to
241*543adbedSBen Gras.Pa /dev/tty
242*543adbedSBen Grascontaining the name of the file and a line is read from
243*543adbedSBen Gras.Pa /dev/tty .
244*543adbedSBen GrasIf the line read is blank, the file is skipped.
245*543adbedSBen GrasIf the line contains a single period, the file is processed normally.
246*543adbedSBen GrasOtherwise, the line is taken to be the new name of the file.
247*543adbedSBen Gras.It Fl t
248*543adbedSBen Gras(i mode only)
249*543adbedSBen GrasList the contents of the archive to stdout;
250*543adbedSBen Grasdo not restore the contents to disk.
251*543adbedSBen Gras.It Fl u
252*543adbedSBen Gras(i and p modes)
253*543adbedSBen GrasUnconditionally overwrite existing files.
254*543adbedSBen GrasOrdinarily, an older file will not overwrite a newer file on disk.
255*543adbedSBen Gras.It Fl v
256*543adbedSBen GrasPrint the name of each file to stderr as it is processed.
257*543adbedSBen GrasWith
258*543adbedSBen Gras.Fl t ,
259*543adbedSBen Grasprovide a detailed listing of each file.
260*543adbedSBen Gras.It Fl -version
261*543adbedSBen GrasPrint the program version information and exit.
262*543adbedSBen Gras.It Fl y
263*543adbedSBen Gras(o mode only)
264*543adbedSBen GrasCompress the archive with bzip2-compatible compression before writing it.
265*543adbedSBen GrasIn input mode, this option is ignored;
266*543adbedSBen Grasbzip2 compression is recognized automatically on input.
267*543adbedSBen Gras.It Fl Z
268*543adbedSBen Gras(o mode only)
269*543adbedSBen GrasCompress the archive with compress-compatible compression before writing it.
270*543adbedSBen GrasIn input mode, this option is ignored;
271*543adbedSBen Grascompression is recognized automatically on input.
272*543adbedSBen Gras.It Fl z
273*543adbedSBen Gras(o mode only)
274*543adbedSBen GrasCompress the archive with gzip-compatible compression before writing it.
275*543adbedSBen GrasIn input mode, this option is ignored;
276*543adbedSBen Grasgzip compression is recognized automatically on input.
277*543adbedSBen Gras.El
278*543adbedSBen Gras.Sh ENVIRONMENT
279*543adbedSBen GrasThe following environment variables affect the execution of
280*543adbedSBen Gras.Nm :
281*543adbedSBen Gras.Bl -tag -width ".Ev BLOCKSIZE"
282*543adbedSBen Gras.It Ev LANG
283*543adbedSBen GrasThe locale to use.
284*543adbedSBen GrasSee
285*543adbedSBen Gras.Xr environ 7
286*543adbedSBen Grasfor more information.
287*543adbedSBen Gras.It Ev TZ
288*543adbedSBen GrasThe timezone to use when displaying dates.
289*543adbedSBen GrasSee
290*543adbedSBen Gras.Xr environ 7
291*543adbedSBen Grasfor more information.
292*543adbedSBen Gras.El
293*543adbedSBen Gras.Sh EXIT STATUS
294*543adbedSBen Gras.Ex -std
295*543adbedSBen Gras.Sh EXAMPLES
296*543adbedSBen GrasThe
297*543adbedSBen Gras.Nm
298*543adbedSBen Grascommand is traditionally used to copy file heirarchies in conjunction
299*543adbedSBen Graswith the
300*543adbedSBen Gras.Xr find 1
301*543adbedSBen Grascommand.
302*543adbedSBen GrasThe first example here simply copies all files from
303*543adbedSBen Gras.Pa src
304*543adbedSBen Grasto
305*543adbedSBen Gras.Pa dest :
306*543adbedSBen Gras.Dl Nm find Pa src | Nm Fl pmud Pa dest
307*543adbedSBen Gras.Pp
308*543adbedSBen GrasBy carefully selecting options to the
309*543adbedSBen Gras.Xr find 1
310*543adbedSBen Grascommand and combining it with other standard utilities,
311*543adbedSBen Grasit is possible to exercise very fine control over which files are copied.
312*543adbedSBen GrasThis next example copies files from
313*543adbedSBen Gras.Pa src
314*543adbedSBen Grasto
315*543adbedSBen Gras.Pa dest
316*543adbedSBen Grasthat are more than 2 days old and whose names match a particular pattern:
317*543adbedSBen Gras.Dl Nm find Pa src Fl mtime Ar +2 | Nm grep foo[bar] | Nm Fl pdmu Pa dest
318*543adbedSBen Gras.Pp
319*543adbedSBen GrasThis example copies files from
320*543adbedSBen Gras.Pa src
321*543adbedSBen Grasto
322*543adbedSBen Gras.Pa dest
323*543adbedSBen Grasthat are more than 2 days old and which contain the word
324*543adbedSBen Gras.Do foobar Dc :
325*543adbedSBen Gras.Dl Nm find Pa src Fl mtime Ar +2 | Nm xargs Nm grep -l foobar | Nm Fl pdmu Pa dest
326*543adbedSBen Gras.Sh COMPATIBILITY
327*543adbedSBen GrasThe mode options i, o, and p and the options
328*543adbedSBen Grasa, B, c, d, f, l, m, r, t, u, and v comply with SUSv2.
329*543adbedSBen Gras.Pp
330*543adbedSBen GrasThe old POSIX.1 standard specified that only
331*543adbedSBen Gras.Fl i ,
332*543adbedSBen Gras.Fl o ,
333*543adbedSBen Grasand
334*543adbedSBen Gras.Fl p
335*543adbedSBen Graswere interpreted as command-line options.
336*543adbedSBen GrasEach took a single argument of a list of modifier
337*543adbedSBen Grascharacters.
338*543adbedSBen GrasFor example, the standard syntax allows
339*543adbedSBen Gras.Fl imu
340*543adbedSBen Grasbut does not support
341*543adbedSBen Gras.Fl miu
342*543adbedSBen Grasor
343*543adbedSBen Gras.Fl i Fl m Fl u ,
344*543adbedSBen Grassince
345*543adbedSBen Gras.Ar m
346*543adbedSBen Grasand
347*543adbedSBen Gras.Ar u
348*543adbedSBen Grasare only modifiers to
349*543adbedSBen Gras.Fl i ,
350*543adbedSBen Grasthey are not command-line options in their own right.
351*543adbedSBen GrasThe syntax supported by this implementation is backwards-compatible
352*543adbedSBen Graswith the standard.
353*543adbedSBen GrasFor best compatibility, scripts should limit themselves to the
354*543adbedSBen Grasstandard syntax.
355*543adbedSBen Gras.Sh SEE ALSO
356*543adbedSBen Gras.Xr bzip2 1 ,
357*543adbedSBen Gras.Xr tar 1 ,
358*543adbedSBen Gras.Xr gzip 1 ,
359*543adbedSBen Gras.Xr mt 1 ,
360*543adbedSBen Gras.Xr pax 1 ,
361*543adbedSBen Gras.Xr libarchive 3 ,
362*543adbedSBen Gras.Xr cpio 5 ,
363*543adbedSBen Gras.Xr libarchive-formats 5 ,
364*543adbedSBen Gras.Xr tar 5
365*543adbedSBen Gras.Sh STANDARDS
366*543adbedSBen GrasThere is no current POSIX standard for the cpio command; it appeared
367*543adbedSBen Grasin
368*543adbedSBen Gras.St -p1003.1-96
369*543adbedSBen Grasbut was dropped from
370*543adbedSBen Gras.St -p1003.1-2001 .
371*543adbedSBen Gras.Pp
372*543adbedSBen GrasThe cpio, ustar, and pax interchange file formats are defined by
373*543adbedSBen Gras.St -p1003.1-2001
374*543adbedSBen Grasfor the pax command.
375*543adbedSBen Gras.Sh HISTORY
376*543adbedSBen GrasThe original
377*543adbedSBen Gras.Nm cpio
378*543adbedSBen Grasand
379*543adbedSBen Gras.Nm find
380*543adbedSBen Grasutilities were written by Dick Haight
381*543adbedSBen Graswhile working in AT&T's Unix Support Group.
382*543adbedSBen GrasThey first appeared in 1977 in PWB/UNIX 1.0, the
383*543adbedSBen Gras.Dq Programmer's Work Bench
384*543adbedSBen Grassystem developed for use within AT&T.
385*543adbedSBen GrasThey were first released outside of AT&T as part of System III Unix in 1981.
386*543adbedSBen GrasAs a result,
387*543adbedSBen Gras.Nm cpio
388*543adbedSBen Grasactually predates
389*543adbedSBen Gras.Nm tar ,
390*543adbedSBen Graseven though it was not well-known outside of AT&T until some time later.
391*543adbedSBen Gras.Pp
392*543adbedSBen GrasThis is a complete re-implementation based on the
393*543adbedSBen Gras.Xr libarchive 3
394*543adbedSBen Graslibrary.
395*543adbedSBen Gras.Sh BUGS
396*543adbedSBen GrasThe cpio archive format has several basic limitations:
397*543adbedSBen GrasIt does not store user and group names, only numbers.
398*543adbedSBen GrasAs a result, it cannot be reliably used to transfer
399*543adbedSBen Grasfiles between systems with dissimilar user and group numbering.
400*543adbedSBen GrasOlder cpio formats limit the user and group numbers to
401*543adbedSBen Gras16 or 18 bits, which is insufficient for modern systems.
402*543adbedSBen GrasThe cpio archive formats cannot support files over 4 gigabytes,
403*543adbedSBen Grasexcept for the
404*543adbedSBen Gras.Dq odc
405*543adbedSBen Grasvariant, which can support files up to 8 gigabytes.
406