xref: /freebsd/contrib/libarchive/tar/bsdtar.1 (revision 6c95142e7977d720e7f1c70672b358aa09fa6bfa)
1caf54c4fSMartin Matuska.\" Copyright (c) 2003-2007 Tim Kientzle
2caf54c4fSMartin Matuska.\" All rights reserved.
3caf54c4fSMartin Matuska.\"
4caf54c4fSMartin Matuska.\" Redistribution and use in source and binary forms, with or without
5caf54c4fSMartin Matuska.\" modification, are permitted provided that the following conditions
6caf54c4fSMartin Matuska.\" are met:
7caf54c4fSMartin Matuska.\" 1. Redistributions of source code must retain the above copyright
8caf54c4fSMartin Matuska.\"    notice, this list of conditions and the following disclaimer.
9caf54c4fSMartin Matuska.\" 2. Redistributions in binary form must reproduce the above copyright
10caf54c4fSMartin Matuska.\"    notice, this list of conditions and the following disclaimer in the
11caf54c4fSMartin Matuska.\"    documentation and/or other materials provided with the distribution.
12caf54c4fSMartin Matuska.\"
13caf54c4fSMartin Matuska.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14caf54c4fSMartin Matuska.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15caf54c4fSMartin Matuska.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16caf54c4fSMartin Matuska.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17caf54c4fSMartin Matuska.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18caf54c4fSMartin Matuska.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19caf54c4fSMartin Matuska.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20caf54c4fSMartin Matuska.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21caf54c4fSMartin Matuska.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22caf54c4fSMartin Matuska.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23caf54c4fSMartin Matuska.\" SUCH DAMAGE.
24caf54c4fSMartin Matuska.\"
256c22d9efSMartin Matuska.\" $FreeBSD$
26caf54c4fSMartin Matuska.\"
27caf54c4fSMartin Matuska.Dd Oct 12, 2009
28*6c95142eSMartin Matuska.Dt TAR 1
29caf54c4fSMartin Matuska.Os
30caf54c4fSMartin Matuska.Sh NAME
31caf54c4fSMartin Matuska.Nm tar
32caf54c4fSMartin Matuska.Nd manipulate tape archives
33caf54c4fSMartin Matuska.Sh SYNOPSIS
34caf54c4fSMartin Matuska.Nm
35caf54c4fSMartin Matuska.Op Ar bundled-flags Ao args Ac
36caf54c4fSMartin Matuska.Op Ao Ar file Ac | Ao Ar pattern Ac ...
37caf54c4fSMartin Matuska.Nm
38caf54c4fSMartin Matuska.Brq Fl c
39caf54c4fSMartin Matuska.Op Ar options
40caf54c4fSMartin Matuska.Op Ar files | Ar directories
41caf54c4fSMartin Matuska.Nm
42caf54c4fSMartin Matuska.Brq Fl r | Fl u
43caf54c4fSMartin Matuska.Fl f Ar archive-file
44caf54c4fSMartin Matuska.Op Ar options
45caf54c4fSMartin Matuska.Op Ar files | Ar directories
46caf54c4fSMartin Matuska.Nm
47caf54c4fSMartin Matuska.Brq Fl t | Fl x
48caf54c4fSMartin Matuska.Op Ar options
49caf54c4fSMartin Matuska.Op Ar patterns
50caf54c4fSMartin Matuska.Sh DESCRIPTION
51caf54c4fSMartin Matuska.Nm
52caf54c4fSMartin Matuskacreates and manipulates streaming archive files.
53c5d360f8SMartin MatuskaThis implementation can extract from tar, pax, cpio, zip, jar, ar, xar,
54*6c95142eSMartin Matuskarpm, 7-zip, and ISO 9660 cdrom images and can create tar, pax, cpio, ar, zip,
55*6c95142eSMartin Matuska7-zip, and shar archives.
56caf54c4fSMartin Matuska.Pp
57caf54c4fSMartin MatuskaThe first synopsis form shows a
58caf54c4fSMartin Matuska.Dq bundled
59caf54c4fSMartin Matuskaoption word.
60caf54c4fSMartin MatuskaThis usage is provided for compatibility with historical implementations.
61caf54c4fSMartin MatuskaSee COMPATIBILITY below for details.
62caf54c4fSMartin Matuska.Pp
63caf54c4fSMartin MatuskaThe other synopsis forms show the preferred usage.
64caf54c4fSMartin MatuskaThe first option to
65caf54c4fSMartin Matuska.Nm
66caf54c4fSMartin Matuskais a mode indicator from the following list:
67caf54c4fSMartin Matuska.Bl -tag -compact -width indent
68caf54c4fSMartin Matuska.It Fl c
69caf54c4fSMartin MatuskaCreate a new archive containing the specified items.
70c5d360f8SMartin MatuskaThe long option form is
71c5d360f8SMartin Matuska.Fl Fl create .
72caf54c4fSMartin Matuska.It Fl r
73caf54c4fSMartin MatuskaLike
74caf54c4fSMartin Matuska.Fl c ,
75caf54c4fSMartin Matuskabut new entries are appended to the archive.
76caf54c4fSMartin MatuskaNote that this only works on uncompressed archives stored in regular files.
77caf54c4fSMartin MatuskaThe
78caf54c4fSMartin Matuska.Fl f
79caf54c4fSMartin Matuskaoption is required.
80c5d360f8SMartin MatuskaThe long option form is
81c5d360f8SMartin Matuska.Fl Fl append .
82caf54c4fSMartin Matuska.It Fl t
83caf54c4fSMartin MatuskaList archive contents to stdout.
84c5d360f8SMartin MatuskaThe long option form is
85c5d360f8SMartin Matuska.Fl Fl list .
86caf54c4fSMartin Matuska.It Fl u
87caf54c4fSMartin MatuskaLike
88caf54c4fSMartin Matuska.Fl r ,
89caf54c4fSMartin Matuskabut new entries are added only if they have a modification date
90caf54c4fSMartin Matuskanewer than the corresponding entry in the archive.
91caf54c4fSMartin MatuskaNote that this only works on uncompressed archives stored in regular files.
92caf54c4fSMartin MatuskaThe
93caf54c4fSMartin Matuska.Fl f
94caf54c4fSMartin Matuskaoption is required.
95c5d360f8SMartin MatuskaThe long form is
96c5d360f8SMartin Matuska.Fl Fl update .
97caf54c4fSMartin Matuska.It Fl x
98caf54c4fSMartin MatuskaExtract to disk from the archive.
99caf54c4fSMartin MatuskaIf a file with the same name appears more than once in the archive,
100caf54c4fSMartin Matuskaeach copy will be extracted, with later copies overwriting (replacing)
101caf54c4fSMartin Matuskaearlier copies.
102c5d360f8SMartin MatuskaThe long option form is
103c5d360f8SMartin Matuska.Fl Fl extract .
104caf54c4fSMartin Matuska.El
105caf54c4fSMartin Matuska.Pp
106caf54c4fSMartin MatuskaIn
107caf54c4fSMartin Matuska.Fl c ,
108caf54c4fSMartin Matuska.Fl r ,
109caf54c4fSMartin Matuskaor
110caf54c4fSMartin Matuska.Fl u
111caf54c4fSMartin Matuskamode, each specified file or directory is added to the
112caf54c4fSMartin Matuskaarchive in the order specified on the command line.
113caf54c4fSMartin MatuskaBy default, the contents of each directory are also archived.
114caf54c4fSMartin Matuska.Pp
115caf54c4fSMartin MatuskaIn extract or list mode, the entire command line
116caf54c4fSMartin Matuskais read and parsed before the archive is opened.
117caf54c4fSMartin MatuskaThe pathnames or patterns on the command line indicate
118caf54c4fSMartin Matuskawhich items in the archive should be processed.
119caf54c4fSMartin MatuskaPatterns are shell-style globbing patterns as
120caf54c4fSMartin Matuskadocumented in
121caf54c4fSMartin Matuska.Xr tcsh 1 .
122caf54c4fSMartin Matuska.Sh OPTIONS
123caf54c4fSMartin MatuskaUnless specifically stated otherwise, options are applicable in
124caf54c4fSMartin Matuskaall operating modes.
125caf54c4fSMartin Matuska.Bl -tag -width indent
126caf54c4fSMartin Matuska.It Cm @ Ns Pa archive
127caf54c4fSMartin Matuska(c and r mode only)
128caf54c4fSMartin MatuskaThe specified archive is opened and the entries
129caf54c4fSMartin Matuskain it will be appended to the current archive.
130caf54c4fSMartin MatuskaAs a simple example,
131caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar
132caf54c4fSMartin Matuskawrites a new archive to standard output containing a file
133caf54c4fSMartin Matuska.Pa newfile
134caf54c4fSMartin Matuskaand all of the entries from
135caf54c4fSMartin Matuska.Pa original.tar .
136caf54c4fSMartin MatuskaIn contrast,
137caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar
138caf54c4fSMartin Matuskacreates a new archive with only two entries.
139caf54c4fSMartin MatuskaSimilarly,
140c5d360f8SMartin Matuska.Dl Nm Fl czf Pa - Fl Fl format Cm pax Cm @ Ns Pa -
141caf54c4fSMartin Matuskareads an archive from standard input (whose format will be determined
142caf54c4fSMartin Matuskaautomatically) and converts it into a gzip-compressed
143caf54c4fSMartin Matuskapax-format archive on stdout.
144caf54c4fSMartin MatuskaIn this way,
145caf54c4fSMartin Matuska.Nm
146caf54c4fSMartin Matuskacan be used to convert archives from one format to another.
147c5d360f8SMartin Matuska.It Fl B , Fl Fl read-full-blocks
148c5d360f8SMartin MatuskaIgnored for compatibility with other
149c5d360f8SMartin Matuska.Xr tar 1
150c5d360f8SMartin Matuskaimplementations.
151c5d360f8SMartin Matuska.It Fl b Ar blocksize , Fl Fl block-size Ar blocksize
152caf54c4fSMartin MatuskaSpecify the block size, in 512-byte records, for tape drive I/O.
153caf54c4fSMartin MatuskaAs a rule, this argument is only needed when reading from or writing
154caf54c4fSMartin Matuskato tape drives, and usually not even then as the default block size of
155caf54c4fSMartin Matuska20 records (10240 bytes) is very common.
156*6c95142eSMartin Matuska.It Fl C Ar directory , Fl Fl cd Ar directory , Fl Fl directory Ar directory
157caf54c4fSMartin MatuskaIn c and r mode, this changes the directory before adding
158caf54c4fSMartin Matuskathe following files.
159caf54c4fSMartin MatuskaIn x mode, change directories after opening the archive
160caf54c4fSMartin Matuskabut before extracting entries from the archive.
161c5d360f8SMartin Matuska.It Fl Fl chroot
162caf54c4fSMartin Matuska(x mode only)
163caf54c4fSMartin Matuska.Fn chroot
164caf54c4fSMartin Matuskato the current directory after processing any
165caf54c4fSMartin Matuska.Fl C
166caf54c4fSMartin Matuskaoptions and before extracting any files.
167c5d360f8SMartin Matuska.It Fl Fl disable-copyfile
168c5d360f8SMartin MatuskaMac OS X specific.
169c5d360f8SMartin MatuskaDisable the use of
170c5d360f8SMartin Matuska.Xr copyfile 3 .
171c5d360f8SMartin Matuska.It Fl Fl exclude Ar pattern
172caf54c4fSMartin MatuskaDo not process files or directories that match the
173caf54c4fSMartin Matuskaspecified pattern.
174caf54c4fSMartin MatuskaNote that exclusions take precedence over patterns or filenames
175caf54c4fSMartin Matuskaspecified on the command line.
176c5d360f8SMartin Matuska.It Fl Fl format Ar format
177caf54c4fSMartin Matuska(c, r, u mode only)
178caf54c4fSMartin MatuskaUse the specified format for the created archive.
179caf54c4fSMartin MatuskaSupported formats include
180caf54c4fSMartin Matuska.Dq cpio ,
181caf54c4fSMartin Matuska.Dq pax ,
182caf54c4fSMartin Matuska.Dq shar ,
183caf54c4fSMartin Matuskaand
184caf54c4fSMartin Matuska.Dq ustar .
185caf54c4fSMartin MatuskaOther formats may also be supported; see
186caf54c4fSMartin Matuska.Xr libarchive-formats 5
187caf54c4fSMartin Matuskafor more information about currently-supported formats.
188caf54c4fSMartin MatuskaIn r and u modes, when extending an existing archive, the format specified
189caf54c4fSMartin Matuskahere must be compatible with the format of the existing archive on disk.
190c5d360f8SMartin Matuska.It Fl f Ar file , Fl Fl file Ar file
191caf54c4fSMartin MatuskaRead the archive from or write the archive to the specified file.
192caf54c4fSMartin MatuskaThe filename can be
193caf54c4fSMartin Matuska.Pa -
194caf54c4fSMartin Matuskafor standard input or standard output.
195c5d360f8SMartin MatuskaThe default varies by system;
196c5d360f8SMartin Matuskaon
197caf54c4fSMartin Matuska.Fx ,
198c5d360f8SMartin Matuskathe default is
199c5d360f8SMartin Matuska.Pa /dev/sa0 ;
200c5d360f8SMartin Matuskaon Linux, the default is
201c5d360f8SMartin Matuska.Pa /dev/st0 .
202caf54c4fSMartin Matuska.It Fl Fl gid Ar id
203caf54c4fSMartin MatuskaUse the provided group id number.
204caf54c4fSMartin MatuskaOn extract, this overrides the group id in the archive;
205caf54c4fSMartin Matuskathe group name in the archive will be ignored.
206caf54c4fSMartin MatuskaOn create, this overrides the group id read from disk;
207caf54c4fSMartin Matuskaif
208caf54c4fSMartin Matuska.Fl Fl gname
209caf54c4fSMartin Matuskais not also specified, the group name will be set to
210caf54c4fSMartin Matuskamatch the group id.
211caf54c4fSMartin Matuska.It Fl Fl gname Ar name
212caf54c4fSMartin MatuskaUse the provided group name.
213caf54c4fSMartin MatuskaOn extract, this overrides the group name in the archive;
214caf54c4fSMartin Matuskaif the provided group name does not exist on the system,
215caf54c4fSMartin Matuskathe group id
216caf54c4fSMartin Matuska(from the archive or from the
217caf54c4fSMartin Matuska.Fl Fl gid
218caf54c4fSMartin Matuskaoption)
219caf54c4fSMartin Matuskawill be used instead.
220caf54c4fSMartin MatuskaOn create, this sets the group name that will be stored
221caf54c4fSMartin Matuskain the archive;
222caf54c4fSMartin Matuskathe name will not be verified against the system group database.
223caf54c4fSMartin Matuska.It Fl H
224caf54c4fSMartin Matuska(c and r mode only)
225caf54c4fSMartin MatuskaSymbolic links named on the command line will be followed; the
226caf54c4fSMartin Matuskatarget of the link will be archived, not the link itself.
227caf54c4fSMartin Matuska.It Fl h
228caf54c4fSMartin Matuska(c and r mode only)
229caf54c4fSMartin MatuskaSynonym for
230caf54c4fSMartin Matuska.Fl L .
231caf54c4fSMartin Matuska.It Fl I
232caf54c4fSMartin MatuskaSynonym for
233caf54c4fSMartin Matuska.Fl T .
234c5d360f8SMartin Matuska.It Fl Fl help
235c5d360f8SMartin MatuskaShow usage.
236c5d360f8SMartin Matuska.It Fl Fl include Ar pattern
237caf54c4fSMartin MatuskaProcess only files or directories that match the specified pattern.
238caf54c4fSMartin MatuskaNote that exclusions specified with
239c5d360f8SMartin Matuska.Fl Fl exclude
240caf54c4fSMartin Matuskatake precedence over inclusions.
241caf54c4fSMartin MatuskaIf no inclusions are explicitly specified, all entries are processed by
242caf54c4fSMartin Matuskadefault.
243caf54c4fSMartin MatuskaThe
244c5d360f8SMartin Matuska.Fl Fl include
245caf54c4fSMartin Matuskaoption is especially useful when filtering archives.
246caf54c4fSMartin MatuskaFor example, the command
247c5d360f8SMartin Matuska.Dl Nm Fl c Fl f Pa new.tar Fl Fl include='*foo*' Cm @ Ns Pa old.tgz
248caf54c4fSMartin Matuskacreates a new archive
249caf54c4fSMartin Matuska.Pa new.tar
250caf54c4fSMartin Matuskacontaining only the entries from
251caf54c4fSMartin Matuska.Pa old.tgz
252caf54c4fSMartin Matuskacontaining the string
253caf54c4fSMartin Matuska.Sq foo .
254c5d360f8SMartin Matuska.It Fl J , Fl Fl xz
255c5d360f8SMartin Matuska(c mode only)
256c5d360f8SMartin MatuskaCompress the resulting archive with
257c5d360f8SMartin Matuska.Xr xz 1 .
258c5d360f8SMartin MatuskaIn extract or list modes, this option is ignored.
259c5d360f8SMartin MatuskaNote that, unlike other
260c5d360f8SMartin Matuska.Nm tar
261c5d360f8SMartin Matuskaimplementations, this implementation recognizes XZ compression
262c5d360f8SMartin Matuskaautomatically when reading archives.
263c5d360f8SMartin Matuska.It Fl j , Fl Fl bzip , Fl Fl bzip2 , Fl Fl bunzip2
264caf54c4fSMartin Matuska(c mode only)
265caf54c4fSMartin MatuskaCompress the resulting archive with
266caf54c4fSMartin Matuska.Xr bzip2 1 .
267caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored.
268caf54c4fSMartin MatuskaNote that, unlike other
269caf54c4fSMartin Matuska.Nm tar
270caf54c4fSMartin Matuskaimplementations, this implementation recognizes bzip2 compression
271caf54c4fSMartin Matuskaautomatically when reading archives.
272c5d360f8SMartin Matuska.It Fl k , Fl Fl keep-old-files
273caf54c4fSMartin Matuska(x mode only)
274caf54c4fSMartin MatuskaDo not overwrite existing files.
275caf54c4fSMartin MatuskaIn particular, if a file appears more than once in an archive,
276caf54c4fSMartin Matuskalater copies will not overwrite earlier copies.
277c5d360f8SMartin Matuska.It Fl Fl keep-newer-files
278caf54c4fSMartin Matuska(x mode only)
279caf54c4fSMartin MatuskaDo not overwrite existing files that are newer than the
280caf54c4fSMartin Matuskaversions appearing in the archive being extracted.
281c5d360f8SMartin Matuska.It Fl L , Fl Fl dereference
282caf54c4fSMartin Matuska(c and r mode only)
283caf54c4fSMartin MatuskaAll symbolic links will be followed.
284caf54c4fSMartin MatuskaNormally, symbolic links are archived as such.
285caf54c4fSMartin MatuskaWith this option, the target of the link will be archived instead.
286c5d360f8SMartin Matuska.It Fl l , Fl Fl check-links
287c5d360f8SMartin Matuska(c and r modes only)
288c5d360f8SMartin MatuskaIssue a warning message unless all links to each file are archived.
289c5d360f8SMartin Matuska.It Fl Fl lzma
290c5d360f8SMartin Matuska(c mode only) Compress the resulting archive with the original LZMA algorithm.
291c5d360f8SMartin MatuskaUse of this option is discouraged and new archives should be created with
292c5d360f8SMartin Matuska.Fl Fl xz
293c5d360f8SMartin Matuskainstead.
294c5d360f8SMartin MatuskaNote that, unlike other
295c5d360f8SMartin Matuska.Nm tar
296c5d360f8SMartin Matuskaimplementations, this implementation recognizes LZMA compression
297c5d360f8SMartin Matuskaautomatically when reading archives.
298c5d360f8SMartin Matuska.It Fl m , Fl Fl modification-time
299caf54c4fSMartin Matuska(x mode only)
300caf54c4fSMartin MatuskaDo not extract modification time.
301caf54c4fSMartin MatuskaBy default, the modification time is set to the time stored in the archive.
302c5d360f8SMartin Matuska.It Fl n , Fl Fl norecurse , Fl Fl no-recursion
303caf54c4fSMartin Matuska(c, r, u modes only)
304caf54c4fSMartin MatuskaDo not recursively archive the contents of directories.
305c5d360f8SMartin Matuska.It Fl Fl newer Ar date
306caf54c4fSMartin Matuska(c, r, u modes only)
307caf54c4fSMartin MatuskaOnly include files and directories newer than the specified date.
308caf54c4fSMartin MatuskaThis compares ctime entries.
309c5d360f8SMartin Matuska.It Fl Fl newer-mtime Ar date
310caf54c4fSMartin Matuska(c, r, u modes only)
311caf54c4fSMartin MatuskaLike
312c5d360f8SMartin Matuska.Fl Fl newer ,
313caf54c4fSMartin Matuskaexcept it compares mtime entries instead of ctime entries.
314c5d360f8SMartin Matuska.It Fl Fl newer-than Pa file
315caf54c4fSMartin Matuska(c, r, u modes only)
316caf54c4fSMartin MatuskaOnly include files and directories newer than the specified file.
317caf54c4fSMartin MatuskaThis compares ctime entries.
318c5d360f8SMartin Matuska.It Fl Fl newer-mtime-than Pa file
319caf54c4fSMartin Matuska(c, r, u modes only)
320caf54c4fSMartin MatuskaLike
321c5d360f8SMartin Matuska.Fl Fl newer-than ,
322caf54c4fSMartin Matuskaexcept it compares mtime entries instead of ctime entries.
323c5d360f8SMartin Matuska.It Fl Fl nodump
324caf54c4fSMartin Matuska(c and r modes only)
325caf54c4fSMartin MatuskaHonor the nodump file flag by skipping this file.
326c5d360f8SMartin Matuska.It Fl Fl null
327caf54c4fSMartin Matuska(use with
328c5d360f8SMartin Matuska.Fl I
329caf54c4fSMartin Matuskaor
330c5d360f8SMartin Matuska.Fl T )
331caf54c4fSMartin MatuskaFilenames or patterns are separated by null characters,
332caf54c4fSMartin Matuskanot by newlines.
333caf54c4fSMartin MatuskaThis is often used to read filenames output by the
334caf54c4fSMartin Matuska.Fl print0
335caf54c4fSMartin Matuskaoption to
336caf54c4fSMartin Matuska.Xr find 1 .
337caf54c4fSMartin Matuska.It Fl Fl no-same-owner
338caf54c4fSMartin Matuska(x mode only)
339caf54c4fSMartin MatuskaDo not extract owner and group IDs.
340caf54c4fSMartin MatuskaThis is the reverse of
341caf54c4fSMartin Matuska.Fl Fl same-owner
342caf54c4fSMartin Matuskaand the default behavior if
343caf54c4fSMartin Matuska.Nm
344caf54c4fSMartin Matuskais run as non-root.
345caf54c4fSMartin Matuska.It Fl Fl no-same-permissions
346caf54c4fSMartin Matuska(x mode only)
347caf54c4fSMartin MatuskaDo not extract full permissions (SGID, SUID, sticky bit, ACLs,
348caf54c4fSMartin Matuskaextended attributes or extended file flags).
349caf54c4fSMartin MatuskaThis is the reverse of
350caf54c4fSMartin Matuska.Fl p
351caf54c4fSMartin Matuskaand the default behavior if
352caf54c4fSMartin Matuska.Nm
353caf54c4fSMartin Matuskais run as non-root.
354caf54c4fSMartin Matuska.It Fl Fl numeric-owner
355caf54c4fSMartin MatuskaThis is equivalent to
356caf54c4fSMartin Matuska.Fl Fl uname
357caf54c4fSMartin Matuska.Qq
358caf54c4fSMartin Matuska.Fl Fl gname
359caf54c4fSMartin Matuska.Qq .
360caf54c4fSMartin MatuskaOn extract, it causes user and group names in the archive
361caf54c4fSMartin Matuskato be ignored in favor of the numeric user and group ids.
362caf54c4fSMartin MatuskaOn create, it causes user and group names to not be stored
363caf54c4fSMartin Matuskain the archive.
364c5d360f8SMartin Matuska.It Fl O , Fl Fl to-stdout
365caf54c4fSMartin Matuska(x, t modes only)
366caf54c4fSMartin MatuskaIn extract (-x) mode, files will be written to standard out rather than
367caf54c4fSMartin Matuskabeing extracted to disk.
368caf54c4fSMartin MatuskaIn list (-t) mode, the file listing will be written to stderr rather than
369caf54c4fSMartin Matuskathe usual stdout.
370caf54c4fSMartin Matuska.It Fl o
371caf54c4fSMartin Matuska(x mode)
372caf54c4fSMartin MatuskaUse the user and group of the user running the program rather
373caf54c4fSMartin Matuskathan those specified in the archive.
374caf54c4fSMartin MatuskaNote that this has no significance unless
375caf54c4fSMartin Matuska.Fl p
376caf54c4fSMartin Matuskais specified, and the program is being run by the root user.
377caf54c4fSMartin MatuskaIn this case, the file modes and flags from
378caf54c4fSMartin Matuskathe archive will be restored, but ACLs or owner information in
379caf54c4fSMartin Matuskathe archive will be discarded.
380caf54c4fSMartin Matuska.It Fl o
381caf54c4fSMartin Matuska(c, r, u mode)
382caf54c4fSMartin MatuskaA synonym for
383c5d360f8SMartin Matuska.Fl Fl format Ar ustar
384c5d360f8SMartin Matuska.It Fl Fl one-file-system
385caf54c4fSMartin Matuska(c, r, and u modes)
386caf54c4fSMartin MatuskaDo not cross mount points.
387c5d360f8SMartin Matuska.It Fl Fl options Ar options
388caf54c4fSMartin MatuskaSelect optional behaviors for particular modules.
389caf54c4fSMartin MatuskaThe argument is a text string containing comma-separated
390caf54c4fSMartin Matuskakeywords and values.
391caf54c4fSMartin MatuskaThese are passed to the modules that handle particular
392caf54c4fSMartin Matuskaformats to control how those formats will behave.
393caf54c4fSMartin MatuskaEach option has one of the following forms:
394caf54c4fSMartin Matuska.Bl -tag -compact -width indent
395caf54c4fSMartin Matuska.It Ar key=value
396caf54c4fSMartin MatuskaThe key will be set to the specified value in every module that supports it.
397caf54c4fSMartin MatuskaModules that do not support this key will ignore it.
398caf54c4fSMartin Matuska.It Ar key
399caf54c4fSMartin MatuskaThe key will be enabled in every module that supports it.
400caf54c4fSMartin MatuskaThis is equivalent to
401caf54c4fSMartin Matuska.Ar key Ns Cm =1 .
402caf54c4fSMartin Matuska.It Ar !key
403caf54c4fSMartin MatuskaThe key will be disabled in every module that supports it.
404caf54c4fSMartin Matuska.It Ar module:key=value , Ar module:key , Ar module:!key
405caf54c4fSMartin MatuskaAs above, but the corresponding key and value will be provided
406caf54c4fSMartin Matuskaonly to modules whose name matches
407caf54c4fSMartin Matuska.Ar module .
408caf54c4fSMartin Matuska.El
409caf54c4fSMartin MatuskaThe currently supported modules and keys are:
410caf54c4fSMartin Matuska.Bl -tag -compact -width indent
411caf54c4fSMartin Matuska.It Cm iso9660:joliet
412caf54c4fSMartin MatuskaSupport Joliet extensions.
413caf54c4fSMartin MatuskaThis is enabled by default, use
414caf54c4fSMartin Matuska.Cm !joliet
415caf54c4fSMartin Matuskaor
416caf54c4fSMartin Matuska.Cm iso9660:!joliet
417caf54c4fSMartin Matuskato disable.
418caf54c4fSMartin Matuska.It Cm iso9660:rockridge
419caf54c4fSMartin MatuskaSupport Rock Ridge extensions.
420caf54c4fSMartin MatuskaThis is enabled by default, use
421caf54c4fSMartin Matuska.Cm !rockridge
422caf54c4fSMartin Matuskaor
423caf54c4fSMartin Matuska.Cm iso9660:!rockridge
424caf54c4fSMartin Matuskato disable.
425caf54c4fSMartin Matuska.It Cm gzip:compression-level
426caf54c4fSMartin MatuskaA decimal integer from 0 to 9 specifying the gzip compression level.
427caf54c4fSMartin Matuska.It Cm xz:compression-level
428caf54c4fSMartin MatuskaA decimal integer from 0 to 9 specifying the xz compression level.
429caf54c4fSMartin Matuska.It Cm mtree: Ns Ar keyword
430caf54c4fSMartin MatuskaThe mtree writer module allows you to specify which mtree keywords
431caf54c4fSMartin Matuskawill be included in the output.
432caf54c4fSMartin MatuskaSupported keywords include:
433caf54c4fSMartin Matuska.Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent ,
434caf54c4fSMartin Matuska.Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 ,
435caf54c4fSMartin Matuska.Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname .
436caf54c4fSMartin MatuskaThe default is equivalent to:
437caf54c4fSMartin Matuska.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
438caf54c4fSMartin Matuska.It Cm mtree:all
439caf54c4fSMartin MatuskaEnables all of the above keywords.
440caf54c4fSMartin MatuskaYou can also use
441caf54c4fSMartin Matuska.Cm mtree:!all
442caf54c4fSMartin Matuskato disable all keywords.
443caf54c4fSMartin Matuska.It Cm mtree:use-set
444caf54c4fSMartin MatuskaEnable generation of
445caf54c4fSMartin Matuska.Cm /set
446caf54c4fSMartin Matuskalines in the output.
447caf54c4fSMartin Matuska.It Cm mtree:indent
448caf54c4fSMartin MatuskaProduce human-readable output by indenting options and splitting lines
449caf54c4fSMartin Matuskato fit into 80 columns.
450caf54c4fSMartin Matuska.It Cm zip:compression Ns = Ns Ar type
451caf54c4fSMartin MatuskaUse
452caf54c4fSMartin Matuska.Ar type
453caf54c4fSMartin Matuskaas compression method.
454caf54c4fSMartin MatuskaSupported values are store (uncompressed) and deflate (gzip algorithm).
455caf54c4fSMartin Matuska.El
456caf54c4fSMartin MatuskaIf a provided option is not supported by any module, that
457caf54c4fSMartin Matuskais a fatal error.
458c5d360f8SMartin Matuska.It Fl P , Fl Fl absolute-paths
459caf54c4fSMartin MatuskaPreserve pathnames.
460caf54c4fSMartin MatuskaBy default, absolute pathnames (those that begin with a /
461caf54c4fSMartin Matuskacharacter) have the leading slash removed both when creating archives
462caf54c4fSMartin Matuskaand extracting from them.
463caf54c4fSMartin MatuskaAlso,
464caf54c4fSMartin Matuska.Nm
465caf54c4fSMartin Matuskawill refuse to extract archive entries whose pathnames contain
466caf54c4fSMartin Matuska.Pa ..
467caf54c4fSMartin Matuskaor whose target directory would be altered by a symlink.
468caf54c4fSMartin MatuskaThis option suppresses these behaviors.
469c5d360f8SMartin Matuska.It Fl p , Fl Fl insecure , Fl Fl preserve-permissions
470caf54c4fSMartin Matuska(x mode only)
471caf54c4fSMartin MatuskaPreserve file permissions.
472caf54c4fSMartin MatuskaAttempt to restore the full permissions, including owner, file modes, file
473caf54c4fSMartin Matuskaflags and ACLs, if available, for each item extracted from the archive.
474c5d360f8SMartin MatuskaThis is the default, if
475caf54c4fSMartin Matuska.Nm
476*6c95142eSMartin Matuskais being run by root and can be overridden by also specifying
477c5d360f8SMartin Matuska.Fl Fl no-same-owner
478c5d360f8SMartin Matuskaand
479c5d360f8SMartin Matuska.Fl Fl no-same-permissions .
480c5d360f8SMartin Matuska.It Fl Fl posix
481c5d360f8SMartin Matuska(c, r, u mode only)
482c5d360f8SMartin MatuskaSynonym for
483c5d360f8SMartin Matuska.Fl Fl format Ar pax
484c5d360f8SMartin Matuska.It Fl q , Fl Fl fast-read
485caf54c4fSMartin Matuska(x and t mode only)
486caf54c4fSMartin MatuskaExtract or list only the first archive entry that matches each pattern
487caf54c4fSMartin Matuskaor filename operand.
488caf54c4fSMartin MatuskaExit as soon as each specified pattern or filename has been matched.
489caf54c4fSMartin MatuskaBy default, the archive is always read to the very end, since
490caf54c4fSMartin Matuskathere can be multiple entries with the same name and, by convention,
491caf54c4fSMartin Matuskalater entries overwrite earlier entries.
492caf54c4fSMartin MatuskaThis option is provided as a performance optimization.
493caf54c4fSMartin Matuska.It Fl S
494caf54c4fSMartin Matuska(x mode only)
495caf54c4fSMartin MatuskaExtract files as sparse files.
496caf54c4fSMartin MatuskaFor every block on disk, check first if it contains only NULL bytes and seek
497caf54c4fSMartin Matuskaover it otherwise.
498c5d360f8SMartin MatuskaThis works similar to the conv=sparse option of dd.
499caf54c4fSMartin Matuska.It Fl s Ar pattern
500caf54c4fSMartin MatuskaModify file or archive member names according to
501caf54c4fSMartin Matuska.Pa pattern .
502caf54c4fSMartin MatuskaThe pattern has the format
503*6c95142eSMartin Matuska.Ar /old/new/ Ns Op ghHprRsS
504caf54c4fSMartin Matuskawhere
505caf54c4fSMartin Matuska.Ar old
506caf54c4fSMartin Matuskais a basic regular expression,
507caf54c4fSMartin Matuska.Ar new
508caf54c4fSMartin Matuskais the replacement string of the matched part,
509caf54c4fSMartin Matuskaand the optional trailing letters modify
510caf54c4fSMartin Matuskahow the replacement is handled.
511caf54c4fSMartin MatuskaIf
512caf54c4fSMartin Matuska.Ar old
513caf54c4fSMartin Matuskais not matched, the pattern is skipped.
514caf54c4fSMartin MatuskaWithin
515caf54c4fSMartin Matuska.Ar new ,
516caf54c4fSMartin Matuska~ is substituted with the match, \e1 to \e9 with the content of
517caf54c4fSMartin Matuskathe corresponding captured group.
518caf54c4fSMartin MatuskaThe optional trailing g specifies that matching should continue
519*6c95142eSMartin Matuskaafter the matched part and stop on the first unmatched pattern.
520caf54c4fSMartin MatuskaThe optional trailing s specifies that the pattern applies to the value
521caf54c4fSMartin Matuskaof symbolic links.
522caf54c4fSMartin MatuskaThe optional trailing p specifies that after a successful substitution
523caf54c4fSMartin Matuskathe original path name and the new path name should be printed to
524caf54c4fSMartin Matuskastandard error.
525*6c95142eSMartin MatuskaOptional trailing H, R, or S characters suppress substitutions
526*6c95142eSMartin Matuskafor hardlink targets, regular filenames, or symlink targets,
527*6c95142eSMartin Matuskarespectively.
528*6c95142eSMartin MatuskaOptional trailing h, r, or s characters enable substitutions
529*6c95142eSMartin Matuskafor hardlink targets, regular filenames, or symlink targets,
530*6c95142eSMartin Matuskarespectively.
531*6c95142eSMartin MatuskaThe default is
532*6c95142eSMartin Matuska.Ar hrs
533*6c95142eSMartin Matuskawhich applies substitutions to all names.
534*6c95142eSMartin MatuskaIn particular, it is never necessary to specify h, r, or s.
535*6c95142eSMartin Matuska.It Fl Fl same-owner
536*6c95142eSMartin Matuska(x mode only)
537*6c95142eSMartin MatuskaExtract owner and group IDs.
538*6c95142eSMartin MatuskaThis is the reverse of
539*6c95142eSMartin Matuska.Fl Fl no-same-owner
540*6c95142eSMartin Matuskaand the default behavior if
541*6c95142eSMartin Matuska.Nm
542*6c95142eSMartin Matuskais run as root.
543*6c95142eSMartin Matuska.It Fl Fl strip-components Ar count
544*6c95142eSMartin MatuskaRemove the specified number of leading path elements.
545*6c95142eSMartin MatuskaPathnames with fewer elements will be silently skipped.
546*6c95142eSMartin MatuskaNote that the pathname is edited after checking inclusion/exclusion patterns
547*6c95142eSMartin Matuskabut before security checks.
548c5d360f8SMartin Matuska.It Fl T Ar filename , Fl Fl files-from Ar filename
549caf54c4fSMartin MatuskaIn x or t mode,
550caf54c4fSMartin Matuska.Nm
551caf54c4fSMartin Matuskawill read the list of names to be extracted from
552caf54c4fSMartin Matuska.Pa filename .
553caf54c4fSMartin MatuskaIn c mode,
554caf54c4fSMartin Matuska.Nm
555caf54c4fSMartin Matuskawill read names to be archived from
556caf54c4fSMartin Matuska.Pa filename .
557caf54c4fSMartin MatuskaThe special name
558caf54c4fSMartin Matuska.Dq -C
559caf54c4fSMartin Matuskaon a line by itself will cause the current directory to be changed to
560caf54c4fSMartin Matuskathe directory specified on the following line.
561caf54c4fSMartin MatuskaNames are terminated by newlines unless
562c5d360f8SMartin Matuska.Fl Fl null
563caf54c4fSMartin Matuskais specified.
564caf54c4fSMartin MatuskaNote that
565c5d360f8SMartin Matuska.Fl Fl null
566caf54c4fSMartin Matuskaalso disables the special handling of lines containing
567caf54c4fSMartin Matuska.Dq -C .
568c5d360f8SMartin Matuska.It Fl Fl totals
569c5d360f8SMartin Matuska(c, r, u mode only)
570c5d360f8SMartin MatuskaAfter archiving all files, print a summary to stderr.
571c5d360f8SMartin Matuska.It Fl U , Fl Fl unlink , Fl Fl unlink-first
572caf54c4fSMartin Matuska(x mode only)
573caf54c4fSMartin MatuskaUnlink files before creating them.
574c5d360f8SMartin MatuskaThis can be a minor performance optimization if most files
575c5d360f8SMartin Matuskaalready exist, but can make things slower if most files
576c5d360f8SMartin Matuskado not already exist.
577c5d360f8SMartin MatuskaThis flag also causes
578caf54c4fSMartin Matuska.Nm
579c5d360f8SMartin Matuskato remove intervening directory symlinks instead of
580c5d360f8SMartin Matuskareporting an error.
581c5d360f8SMartin MatuskaSee the SECURITY section below for more details.
582caf54c4fSMartin Matuska.It Fl Fl uid Ar id
583caf54c4fSMartin MatuskaUse the provided user id number and ignore the user
584caf54c4fSMartin Matuskaname from the archive.
585caf54c4fSMartin MatuskaOn create, if
586caf54c4fSMartin Matuska.Fl Fl uname
587caf54c4fSMartin Matuskais not also specified, the user name will be set to
588caf54c4fSMartin Matuskamatch the user id.
589caf54c4fSMartin Matuska.It Fl Fl uname Ar name
590caf54c4fSMartin MatuskaUse the provided user name.
591caf54c4fSMartin MatuskaOn extract, this overrides the user name in the archive;
592caf54c4fSMartin Matuskaif the provided user name does not exist on the system,
593caf54c4fSMartin Matuskait will be ignored and the user id
594caf54c4fSMartin Matuska(from the archive or from the
595caf54c4fSMartin Matuska.Fl Fl uid
596caf54c4fSMartin Matuskaoption)
597caf54c4fSMartin Matuskawill be used instead.
598caf54c4fSMartin MatuskaOn create, this sets the user name that will be stored
599caf54c4fSMartin Matuskain the archive;
600caf54c4fSMartin Matuskathe name is not verified against the system user database.
601caf54c4fSMartin Matuska.It Fl Fl use-compress-program Ar program
602caf54c4fSMartin MatuskaPipe the input (in x or t mode) or the output (in c mode) through
603caf54c4fSMartin Matuska.Pa program
604caf54c4fSMartin Matuskainstead of using the builtin compression support.
605c5d360f8SMartin Matuska.It Fl v , Fl Fl verbose
606caf54c4fSMartin MatuskaProduce verbose output.
607caf54c4fSMartin MatuskaIn create and extract modes,
608caf54c4fSMartin Matuska.Nm
609caf54c4fSMartin Matuskawill list each file name as it is read from or written to
610caf54c4fSMartin Matuskathe archive.
611caf54c4fSMartin MatuskaIn list mode,
612caf54c4fSMartin Matuska.Nm
613caf54c4fSMartin Matuskawill produce output similar to that of
614caf54c4fSMartin Matuska.Xr ls 1 .
615caf54c4fSMartin MatuskaAdditional
616caf54c4fSMartin Matuska.Fl v
617caf54c4fSMartin Matuskaoptions will provide additional detail.
618c5d360f8SMartin Matuska.It Fl Fl version
619caf54c4fSMartin MatuskaPrint version of
620caf54c4fSMartin Matuska.Nm
621caf54c4fSMartin Matuskaand
622caf54c4fSMartin Matuska.Nm libarchive ,
623caf54c4fSMartin Matuskaand exit.
624c5d360f8SMartin Matuska.It Fl w , Fl Fl confirmation , Fl Fl interactive
625caf54c4fSMartin MatuskaAsk for confirmation for every action.
626c5d360f8SMartin Matuska.It Fl X Ar filename , Fl Fl exclude-from Ar filename
627caf54c4fSMartin MatuskaRead a list of exclusion patterns from the specified file.
628caf54c4fSMartin MatuskaSee
629c5d360f8SMartin Matuska.Fl Fl exclude
630caf54c4fSMartin Matuskafor more information about the handling of exclusions.
631caf54c4fSMartin Matuska.It Fl y
632caf54c4fSMartin Matuska(c mode only)
633caf54c4fSMartin MatuskaCompress the resulting archive with
634caf54c4fSMartin Matuska.Xr bzip2 1 .
635caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored.
636caf54c4fSMartin MatuskaNote that, unlike other
637caf54c4fSMartin Matuska.Nm tar
638caf54c4fSMartin Matuskaimplementations, this implementation recognizes bzip2 compression
639caf54c4fSMartin Matuskaautomatically when reading archives.
640c5d360f8SMartin Matuska.It Fl Z , Fl Fl compress , Fl Fl uncompress
641caf54c4fSMartin Matuska(c mode only)
642caf54c4fSMartin MatuskaCompress the resulting archive with
643caf54c4fSMartin Matuska.Xr compress 1 .
644caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored.
645caf54c4fSMartin MatuskaNote that, unlike other
646caf54c4fSMartin Matuska.Nm tar
647caf54c4fSMartin Matuskaimplementations, this implementation recognizes compress compression
648caf54c4fSMartin Matuskaautomatically when reading archives.
649c5d360f8SMartin Matuska.It Fl z , Fl Fl gunzip , Fl Fl gzip
650c5d360f8SMartin Matuska(c mode only)
651c5d360f8SMartin MatuskaCompress the resulting archive with
652c5d360f8SMartin Matuska.Xr gzip 1 .
653c5d360f8SMartin MatuskaIn extract or list modes, this option is ignored.
654c5d360f8SMartin MatuskaNote that, unlike other
655c5d360f8SMartin Matuska.Nm tar
656c5d360f8SMartin Matuskaimplementations, this implementation recognizes gzip compression
657c5d360f8SMartin Matuskaautomatically when reading archives.
658caf54c4fSMartin Matuska.El
659caf54c4fSMartin Matuska.Sh ENVIRONMENT
660caf54c4fSMartin MatuskaThe following environment variables affect the execution of
661caf54c4fSMartin Matuska.Nm :
662caf54c4fSMartin Matuska.Bl -tag -width ".Ev BLOCKSIZE"
663caf54c4fSMartin Matuska.It Ev LANG
664caf54c4fSMartin MatuskaThe locale to use.
665caf54c4fSMartin MatuskaSee
666caf54c4fSMartin Matuska.Xr environ 7
667caf54c4fSMartin Matuskafor more information.
668caf54c4fSMartin Matuska.It Ev TAPE
669c5d360f8SMartin MatuskaThe default device.
670caf54c4fSMartin MatuskaThe
671caf54c4fSMartin Matuska.Fl f
672caf54c4fSMartin Matuskaoption overrides this.
673c5d360f8SMartin MatuskaPlease see the description of the
674c5d360f8SMartin Matuska.Fl f
675c5d360f8SMartin Matuskaoption above for more details.
676caf54c4fSMartin Matuska.It Ev TZ
677caf54c4fSMartin MatuskaThe timezone to use when displaying dates.
678caf54c4fSMartin MatuskaSee
679caf54c4fSMartin Matuska.Xr environ 7
680caf54c4fSMartin Matuskafor more information.
681caf54c4fSMartin Matuska.El
682c5d360f8SMartin Matuska.Sh EXIT STATUS
683c5d360f8SMartin Matuska.Ex -std
684caf54c4fSMartin Matuska.Sh EXAMPLES
685caf54c4fSMartin MatuskaThe following creates a new archive
686caf54c4fSMartin Matuskacalled
687caf54c4fSMartin Matuska.Ar file.tar.gz
688caf54c4fSMartin Matuskathat contains two files
689caf54c4fSMartin Matuska.Ar source.c
690caf54c4fSMartin Matuskaand
691caf54c4fSMartin Matuska.Ar source.h :
692caf54c4fSMartin Matuska.Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h
693caf54c4fSMartin Matuska.Pp
694caf54c4fSMartin MatuskaTo view a detailed table of contents for this
695caf54c4fSMartin Matuskaarchive:
696caf54c4fSMartin Matuska.Dl Nm Fl tvf Pa file.tar.gz
697caf54c4fSMartin Matuska.Pp
698caf54c4fSMartin MatuskaTo extract all entries from the archive on
699caf54c4fSMartin Matuskathe default tape drive:
700caf54c4fSMartin Matuska.Dl Nm Fl x
701caf54c4fSMartin Matuska.Pp
702caf54c4fSMartin MatuskaTo examine the contents of an ISO 9660 cdrom image:
703caf54c4fSMartin Matuska.Dl Nm Fl tf Pa image.iso
704caf54c4fSMartin Matuska.Pp
705caf54c4fSMartin MatuskaTo move file hierarchies, invoke
706caf54c4fSMartin Matuska.Nm
707caf54c4fSMartin Matuskaas
708caf54c4fSMartin Matuska.Dl Nm Fl cf Pa - Fl C Pa srcdir\ . | Nm Fl xpf Pa - Fl C Pa destdir
709caf54c4fSMartin Matuskaor more traditionally
710caf54c4fSMartin Matuska.Dl cd srcdir \&; Nm Fl cf Pa -\ . | ( cd destdir \&; Nm Fl xpf Pa - )
711caf54c4fSMartin Matuska.Pp
712caf54c4fSMartin MatuskaIn create mode, the list of files and directories to be archived
713caf54c4fSMartin Matuskacan also include directory change instructions of the form
714caf54c4fSMartin Matuska.Cm -C Ns Pa foo/baz
715caf54c4fSMartin Matuskaand archive inclusions of the form
716caf54c4fSMartin Matuska.Cm @ Ns Pa archive-file .
717caf54c4fSMartin MatuskaFor example, the command line
718caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2
719caf54c4fSMartin Matuskawill create a new archive
720caf54c4fSMartin Matuska.Pa new.tar .
721caf54c4fSMartin Matuska.Nm
722caf54c4fSMartin Matuskawill read the file
723caf54c4fSMartin Matuska.Pa foo1
724caf54c4fSMartin Matuskafrom the current directory and add it to the output archive.
725caf54c4fSMartin MatuskaIt will then read each entry from
726caf54c4fSMartin Matuska.Pa old.tgz
727caf54c4fSMartin Matuskaand add those entries to the output archive.
728caf54c4fSMartin MatuskaFinally, it will switch to the
729caf54c4fSMartin Matuska.Pa /tmp
730caf54c4fSMartin Matuskadirectory and add
731caf54c4fSMartin Matuska.Pa foo2
732caf54c4fSMartin Matuskato the output archive.
733caf54c4fSMartin Matuska.Pp
734caf54c4fSMartin MatuskaAn input file in
735caf54c4fSMartin Matuska.Xr mtree 5
736caf54c4fSMartin Matuskaformat can be used to create an output archive with arbitrary ownership,
737caf54c4fSMartin Matuskapermissions, or names that differ from existing data on disk:
738caf54c4fSMartin Matuska.Pp
739caf54c4fSMartin Matuska.Dl $ cat input.mtree
740caf54c4fSMartin Matuska.Dl #mtree
741caf54c4fSMartin Matuska.Dl usr/bin uid=0 gid=0 mode=0755 type=dir
742caf54c4fSMartin Matuska.Dl usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls
743caf54c4fSMartin Matuska.Dl $ tar -cvf output.tar @input.mtree
744caf54c4fSMartin Matuska.Pp
745caf54c4fSMartin MatuskaThe
746c5d360f8SMartin Matuska.Fl Fl newer
747caf54c4fSMartin Matuskaand
748c5d360f8SMartin Matuska.Fl Fl newer-mtime
749caf54c4fSMartin Matuskaswitches accept a variety of common date and time specifications, including
750caf54c4fSMartin Matuska.Dq 12 Mar 2005 7:14:29pm ,
751caf54c4fSMartin Matuska.Dq 2005-03-12 19:14 ,
752caf54c4fSMartin Matuska.Dq 5 minutes ago ,
753caf54c4fSMartin Matuskaand
754caf54c4fSMartin Matuska.Dq 19:14 PST May 1 .
755caf54c4fSMartin Matuska.Pp
756caf54c4fSMartin MatuskaThe
757c5d360f8SMartin Matuska.Fl Fl options
758caf54c4fSMartin Matuskaargument can be used to control various details of archive generation
759caf54c4fSMartin Matuskaor reading.
760caf54c4fSMartin MatuskaFor example, you can generate mtree output which only contains
761caf54c4fSMartin Matuska.Cm type , Cm time ,
762caf54c4fSMartin Matuskaand
763caf54c4fSMartin Matuska.Cm uid
764caf54c4fSMartin Matuskakeywords:
765c5d360f8SMartin Matuska.Dl Nm Fl cf Pa file.tar Fl Fl format=mtree Fl Fl options='!all,type,time,uid' Pa dir
766caf54c4fSMartin Matuskaor you can set the compression level used by gzip or xz compression:
767c5d360f8SMartin Matuska.Dl Nm Fl czf Pa file.tar Fl Fl options='compression-level=9' .
768caf54c4fSMartin MatuskaFor more details, see the explanation of the
769caf54c4fSMartin Matuska.Fn archive_read_set_options
770caf54c4fSMartin Matuskaand
771caf54c4fSMartin Matuska.Fn archive_write_set_options
772caf54c4fSMartin MatuskaAPI calls that are described in
773caf54c4fSMartin Matuska.Xr archive_read 3
774caf54c4fSMartin Matuskaand
775caf54c4fSMartin Matuska.Xr archive_write 3 .
776caf54c4fSMartin Matuska.Sh COMPATIBILITY
777caf54c4fSMartin MatuskaThe bundled-arguments format is supported for compatibility
778caf54c4fSMartin Matuskawith historic implementations.
779caf54c4fSMartin MatuskaIt consists of an initial word (with no leading - character) in which
780caf54c4fSMartin Matuskaeach character indicates an option.
781caf54c4fSMartin MatuskaArguments follow as separate words.
782caf54c4fSMartin MatuskaThe order of the arguments must match the order
783caf54c4fSMartin Matuskaof the corresponding characters in the bundled command word.
784caf54c4fSMartin MatuskaFor example,
785caf54c4fSMartin Matuska.Dl Nm Cm tbf 32 Pa file.tar
786caf54c4fSMartin Matuskaspecifies three flags
787caf54c4fSMartin Matuska.Cm t ,
788caf54c4fSMartin Matuska.Cm b ,
789caf54c4fSMartin Matuskaand
790caf54c4fSMartin Matuska.Cm f .
791caf54c4fSMartin MatuskaThe
792caf54c4fSMartin Matuska.Cm b
793caf54c4fSMartin Matuskaand
794caf54c4fSMartin Matuska.Cm f
795caf54c4fSMartin Matuskaflags both require arguments,
796caf54c4fSMartin Matuskaso there must be two additional items
797caf54c4fSMartin Matuskaon the command line.
798caf54c4fSMartin MatuskaThe
799caf54c4fSMartin Matuska.Ar 32
800caf54c4fSMartin Matuskais the argument to the
801caf54c4fSMartin Matuska.Cm b
802caf54c4fSMartin Matuskaflag, and
803caf54c4fSMartin Matuska.Ar file.tar
804caf54c4fSMartin Matuskais the argument to the
805caf54c4fSMartin Matuska.Cm f
806caf54c4fSMartin Matuskaflag.
807caf54c4fSMartin Matuska.Pp
808caf54c4fSMartin MatuskaThe mode options c, r, t, u, and x and the options
809caf54c4fSMartin Matuskab, f, l, m, o, v, and w comply with SUSv2.
810caf54c4fSMartin Matuska.Pp
811caf54c4fSMartin MatuskaFor maximum portability, scripts that invoke
812caf54c4fSMartin Matuska.Nm tar
813caf54c4fSMartin Matuskashould use the bundled-argument format above, should limit
814caf54c4fSMartin Matuskathemselves to the
815caf54c4fSMartin Matuska.Cm c ,
816caf54c4fSMartin Matuska.Cm t ,
817caf54c4fSMartin Matuskaand
818caf54c4fSMartin Matuska.Cm x
819caf54c4fSMartin Matuskamodes, and the
820caf54c4fSMartin Matuska.Cm b ,
821caf54c4fSMartin Matuska.Cm f ,
822caf54c4fSMartin Matuska.Cm m ,
823caf54c4fSMartin Matuska.Cm v ,
824caf54c4fSMartin Matuskaand
825caf54c4fSMartin Matuska.Cm w
826caf54c4fSMartin Matuskaoptions.
827caf54c4fSMartin Matuska.Pp
828caf54c4fSMartin MatuskaAdditional long options are provided to improve compatibility with other
829caf54c4fSMartin Matuskatar implementations.
830caf54c4fSMartin Matuska.Sh SECURITY
831caf54c4fSMartin MatuskaCertain security issues are common to many archiving programs, including
832caf54c4fSMartin Matuska.Nm .
833caf54c4fSMartin MatuskaIn particular, carefully-crafted archives can request that
834caf54c4fSMartin Matuska.Nm
835caf54c4fSMartin Matuskaextract files to locations outside of the target directory.
836caf54c4fSMartin MatuskaThis can potentially be used to cause unwitting users to overwrite
837caf54c4fSMartin Matuskafiles they did not intend to overwrite.
838caf54c4fSMartin MatuskaIf the archive is being extracted by the superuser, any file
839caf54c4fSMartin Matuskaon the system can potentially be overwritten.
840caf54c4fSMartin MatuskaThere are three ways this can happen.
841caf54c4fSMartin MatuskaAlthough
842caf54c4fSMartin Matuska.Nm
843caf54c4fSMartin Matuskahas mechanisms to protect against each one,
844caf54c4fSMartin Matuskasavvy users should be aware of the implications:
845caf54c4fSMartin Matuska.Bl -bullet -width indent
846caf54c4fSMartin Matuska.It
847caf54c4fSMartin MatuskaArchive entries can have absolute pathnames.
848caf54c4fSMartin MatuskaBy default,
849caf54c4fSMartin Matuska.Nm
850caf54c4fSMartin Matuskaremoves the leading
851caf54c4fSMartin Matuska.Pa /
852caf54c4fSMartin Matuskacharacter from filenames before restoring them to guard against this problem.
853caf54c4fSMartin Matuska.It
854caf54c4fSMartin MatuskaArchive entries can have pathnames that include
855caf54c4fSMartin Matuska.Pa ..
856caf54c4fSMartin Matuskacomponents.
857caf54c4fSMartin MatuskaBy default,
858caf54c4fSMartin Matuska.Nm
859caf54c4fSMartin Matuskawill not extract files containing
860caf54c4fSMartin Matuska.Pa ..
861caf54c4fSMartin Matuskacomponents in their pathname.
862caf54c4fSMartin Matuska.It
863caf54c4fSMartin MatuskaArchive entries can exploit symbolic links to restore
864caf54c4fSMartin Matuskafiles to other directories.
865caf54c4fSMartin MatuskaAn archive can restore a symbolic link to another directory,
866caf54c4fSMartin Matuskathen use that link to restore a file into that directory.
867caf54c4fSMartin MatuskaTo guard against this,
868caf54c4fSMartin Matuska.Nm
869caf54c4fSMartin Matuskachecks each extracted path for symlinks.
870caf54c4fSMartin MatuskaIf the final path element is a symlink, it will be removed
871caf54c4fSMartin Matuskaand replaced with the archive entry.
872caf54c4fSMartin MatuskaIf
873caf54c4fSMartin Matuska.Fl U
874caf54c4fSMartin Matuskais specified, any intermediate symlink will also be unconditionally removed.
875caf54c4fSMartin MatuskaIf neither
876caf54c4fSMartin Matuska.Fl U
877caf54c4fSMartin Matuskanor
878caf54c4fSMartin Matuska.Fl P
879caf54c4fSMartin Matuskais specified,
880caf54c4fSMartin Matuska.Nm
881caf54c4fSMartin Matuskawill refuse to extract the entry.
882caf54c4fSMartin Matuska.El
883caf54c4fSMartin MatuskaTo protect yourself, you should be wary of any archives that
884caf54c4fSMartin Matuskacome from untrusted sources.
885caf54c4fSMartin MatuskaYou should examine the contents of an archive with
886caf54c4fSMartin Matuska.Dl Nm Fl tf Pa filename
887caf54c4fSMartin Matuskabefore extraction.
888caf54c4fSMartin MatuskaYou should use the
889caf54c4fSMartin Matuska.Fl k
890caf54c4fSMartin Matuskaoption to ensure that
891caf54c4fSMartin Matuska.Nm
892caf54c4fSMartin Matuskawill not overwrite any existing files or the
893caf54c4fSMartin Matuska.Fl U
894caf54c4fSMartin Matuskaoption to remove any pre-existing files.
895caf54c4fSMartin MatuskaYou should generally not extract archives while running with super-user
896caf54c4fSMartin Matuskaprivileges.
897caf54c4fSMartin MatuskaNote that the
898caf54c4fSMartin Matuska.Fl P
899caf54c4fSMartin Matuskaoption to
900caf54c4fSMartin Matuska.Nm
901caf54c4fSMartin Matuskadisables the security checks above and allows you to extract
902caf54c4fSMartin Matuskaan archive while preserving any absolute pathnames,
903caf54c4fSMartin Matuska.Pa ..
904caf54c4fSMartin Matuskacomponents, or symlinks to other directories.
905caf54c4fSMartin Matuska.Sh SEE ALSO
906caf54c4fSMartin Matuska.Xr bzip2 1 ,
907caf54c4fSMartin Matuska.Xr compress 1 ,
908caf54c4fSMartin Matuska.Xr cpio 1 ,
909caf54c4fSMartin Matuska.Xr gzip 1 ,
910caf54c4fSMartin Matuska.Xr mt 1 ,
911caf54c4fSMartin Matuska.Xr pax 1 ,
912caf54c4fSMartin Matuska.Xr shar 1 ,
913c5d360f8SMartin Matuska.Xr xz 1 ,
914caf54c4fSMartin Matuska.Xr libarchive 3 ,
915caf54c4fSMartin Matuska.Xr libarchive-formats 5 ,
916caf54c4fSMartin Matuska.Xr tar 5
917caf54c4fSMartin Matuska.Sh STANDARDS
918caf54c4fSMartin MatuskaThere is no current POSIX standard for the tar command; it appeared
919caf54c4fSMartin Matuskain
920caf54c4fSMartin Matuska.St -p1003.1-96
921caf54c4fSMartin Matuskabut was dropped from
922caf54c4fSMartin Matuska.St -p1003.1-2001 .
923c5d360f8SMartin MatuskaThe options supported by this implementation were developed by surveying a
924caf54c4fSMartin Matuskanumber of existing tar implementations as well as the old POSIX specification
925caf54c4fSMartin Matuskafor tar and the current POSIX specification for pax.
926caf54c4fSMartin Matuska.Pp
927caf54c4fSMartin MatuskaThe ustar and pax interchange file formats are defined by
928caf54c4fSMartin Matuska.St -p1003.1-2001
929caf54c4fSMartin Matuskafor the pax command.
930caf54c4fSMartin Matuska.Sh HISTORY
931caf54c4fSMartin MatuskaA
932caf54c4fSMartin Matuska.Nm tar
933caf54c4fSMartin Matuskacommand appeared in Seventh Edition Unix, which was released in January, 1979.
934caf54c4fSMartin MatuskaThere have been numerous other implementations,
935caf54c4fSMartin Matuskamany of which extended the file format.
936caf54c4fSMartin MatuskaJohn Gilmore's
937caf54c4fSMartin Matuska.Nm pdtar
938caf54c4fSMartin Matuskapublic-domain implementation (circa November, 1987)
939caf54c4fSMartin Matuskawas quite influential, and formed the basis of GNU tar.
940caf54c4fSMartin MatuskaGNU tar was included as the standard system tar
941caf54c4fSMartin Matuskain
942caf54c4fSMartin Matuska.Fx
943caf54c4fSMartin Matuskabeginning with
944caf54c4fSMartin Matuska.Fx 1.0 .
945caf54c4fSMartin Matuska.Pp
946caf54c4fSMartin MatuskaThis is a complete re-implementation based on the
947caf54c4fSMartin Matuska.Xr libarchive 3
948caf54c4fSMartin Matuskalibrary.
949c5d360f8SMartin MatuskaIt was first released with
950c5d360f8SMartin Matuska.Fx 5.4
951c5d360f8SMartin Matuskain May, 2005.
952caf54c4fSMartin Matuska.Sh BUGS
953caf54c4fSMartin MatuskaThis program follows
954caf54c4fSMartin Matuska.St -p1003.1-96
955caf54c4fSMartin Matuskafor the definition of the
956caf54c4fSMartin Matuska.Fl l
957caf54c4fSMartin Matuskaoption.
958caf54c4fSMartin MatuskaNote that GNU tar prior to version 1.15 treated
959caf54c4fSMartin Matuska.Fl l
960caf54c4fSMartin Matuskaas a synonym for the
961c5d360f8SMartin Matuska.Fl Fl one-file-system
962caf54c4fSMartin Matuskaoption.
963caf54c4fSMartin Matuska.Pp
964caf54c4fSMartin MatuskaThe
965caf54c4fSMartin Matuska.Fl C Pa dir
966caf54c4fSMartin Matuskaoption may differ from historic implementations.
967caf54c4fSMartin Matuska.Pp
968caf54c4fSMartin MatuskaAll archive output is written in correctly-sized blocks, even
969caf54c4fSMartin Matuskaif the output is being compressed.
970caf54c4fSMartin MatuskaWhether or not the last output block is padded to a full
971caf54c4fSMartin Matuskablock size varies depending on the format and the
972caf54c4fSMartin Matuskaoutput device.
973caf54c4fSMartin MatuskaFor tar and cpio formats, the last block of output is padded
974caf54c4fSMartin Matuskato a full block size if the output is being
975caf54c4fSMartin Matuskawritten to standard output or to a character or block device such as
976caf54c4fSMartin Matuskaa tape drive.
977caf54c4fSMartin MatuskaIf the output is being written to a regular file, the last block
978caf54c4fSMartin Matuskawill not be padded.
979caf54c4fSMartin MatuskaMany compressors, including
980caf54c4fSMartin Matuska.Xr gzip 1
981caf54c4fSMartin Matuskaand
982caf54c4fSMartin Matuska.Xr bzip2 1 ,
983caf54c4fSMartin Matuskacomplain about the null padding when decompressing an archive created by
984caf54c4fSMartin Matuska.Nm ,
985caf54c4fSMartin Matuskaalthough they still extract it correctly.
986caf54c4fSMartin Matuska.Pp
987caf54c4fSMartin MatuskaThe compression and decompression is implemented internally, so
988caf54c4fSMartin Matuskathere may be insignificant differences between the compressed output
989caf54c4fSMartin Matuskagenerated by
990caf54c4fSMartin Matuska.Dl Nm Fl czf Pa - file
991caf54c4fSMartin Matuskaand that generated by
992caf54c4fSMartin Matuska.Dl Nm Fl cf Pa - file | Nm gzip
993caf54c4fSMartin Matuska.Pp
994caf54c4fSMartin MatuskaThe default should be to read and write archives to the standard I/O paths,
995caf54c4fSMartin Matuskabut tradition (and POSIX) dictates otherwise.
996caf54c4fSMartin Matuska.Pp
997caf54c4fSMartin MatuskaThe
998caf54c4fSMartin Matuska.Cm r
999caf54c4fSMartin Matuskaand
1000caf54c4fSMartin Matuska.Cm u
1001caf54c4fSMartin Matuskamodes require that the archive be uncompressed
1002caf54c4fSMartin Matuskaand located in a regular file on disk.
1003caf54c4fSMartin MatuskaOther archives can be modified using
1004caf54c4fSMartin Matuska.Cm c
1005caf54c4fSMartin Matuskamode with the
1006caf54c4fSMartin Matuska.Pa @archive-file
1007caf54c4fSMartin Matuskaextension.
1008caf54c4fSMartin Matuska.Pp
1009caf54c4fSMartin MatuskaTo archive a file called
1010caf54c4fSMartin Matuska.Pa @foo
1011caf54c4fSMartin Matuskaor
1012caf54c4fSMartin Matuska.Pa -foo
1013caf54c4fSMartin Matuskayou must specify it as
1014caf54c4fSMartin Matuska.Pa ./@foo
1015caf54c4fSMartin Matuskaor
1016caf54c4fSMartin Matuska.Pa ./-foo ,
1017caf54c4fSMartin Matuskarespectively.
1018caf54c4fSMartin Matuska.Pp
1019caf54c4fSMartin MatuskaIn create mode, a leading
1020caf54c4fSMartin Matuska.Pa ./
1021caf54c4fSMartin Matuskais always removed.
1022caf54c4fSMartin MatuskaA leading
1023caf54c4fSMartin Matuska.Pa /
1024caf54c4fSMartin Matuskais stripped unless the
1025caf54c4fSMartin Matuska.Fl P
1026caf54c4fSMartin Matuskaoption is specified.
1027caf54c4fSMartin Matuska.Pp
1028caf54c4fSMartin MatuskaThere needs to be better support for file selection on both create
1029caf54c4fSMartin Matuskaand extract.
1030caf54c4fSMartin Matuska.Pp
1031caf54c4fSMartin MatuskaThere is not yet any support for multi-volume archives or for archiving
1032caf54c4fSMartin Matuskasparse files.
1033caf54c4fSMartin Matuska.Pp
1034caf54c4fSMartin MatuskaConverting between dissimilar archive formats (such as tar and cpio) using the
1035caf54c4fSMartin Matuska.Cm @ Ns Pa -
1036caf54c4fSMartin Matuskaconvention can cause hard link information to be lost.
1037caf54c4fSMartin Matuska(This is a consequence of the incompatible ways that different archive
1038caf54c4fSMartin Matuskaformats store hardlink information.)
1039