xref: /freebsd/contrib/libarchive/tar/bsdtar.1 (revision bd66c1b43e33540205dbc1187c2f2a15c58b57ba)
1*bd66c1b4SMartin Matuska.\"
2*bd66c1b4SMartin Matuska.\" SPDX-License-Identifier: BSD-2-Clause
3*bd66c1b4SMartin Matuska.\"
4caf54c4fSMartin Matuska.\" Copyright (c) 2003-2007 Tim Kientzle
564287048SMartin Matuska.\" Copyright (c) 2017 Martin Matuska
6caf54c4fSMartin Matuska.\" All rights reserved.
7caf54c4fSMartin Matuska.\"
813d826ffSMartin Matuska.Dd April 23, 2024
96c95142eSMartin Matuska.Dt TAR 1
10caf54c4fSMartin Matuska.Os
11caf54c4fSMartin Matuska.Sh NAME
12caf54c4fSMartin Matuska.Nm tar
13caf54c4fSMartin Matuska.Nd manipulate tape archives
14caf54c4fSMartin Matuska.Sh SYNOPSIS
15caf54c4fSMartin Matuska.Nm
16caf54c4fSMartin Matuska.Op Ar bundled-flags Ao args Ac
17caf54c4fSMartin Matuska.Op Ao Ar file Ac | Ao Ar pattern Ac ...
18caf54c4fSMartin Matuska.Nm
19caf54c4fSMartin Matuska.Brq Fl c
20caf54c4fSMartin Matuska.Op Ar options
21caf54c4fSMartin Matuska.Op Ar files | Ar directories
22caf54c4fSMartin Matuska.Nm
23caf54c4fSMartin Matuska.Brq Fl r | Fl u
24caf54c4fSMartin Matuska.Fl f Ar archive-file
25caf54c4fSMartin Matuska.Op Ar options
26caf54c4fSMartin Matuska.Op Ar files | Ar directories
27caf54c4fSMartin Matuska.Nm
28caf54c4fSMartin Matuska.Brq Fl t | Fl x
29caf54c4fSMartin Matuska.Op Ar options
30caf54c4fSMartin Matuska.Op Ar patterns
31caf54c4fSMartin Matuska.Sh DESCRIPTION
32caf54c4fSMartin Matuska.Nm
33caf54c4fSMartin Matuskacreates and manipulates streaming archive files.
34c5d360f8SMartin MatuskaThis implementation can extract from tar, pax, cpio, zip, jar, ar, xar,
356c95142eSMartin Matuskarpm, 7-zip, and ISO 9660 cdrom images and can create tar, pax, cpio, ar, zip,
366c95142eSMartin Matuska7-zip, and shar archives.
37caf54c4fSMartin Matuska.Pp
38caf54c4fSMartin MatuskaThe first synopsis form shows a
39caf54c4fSMartin Matuska.Dq bundled
40caf54c4fSMartin Matuskaoption word.
41caf54c4fSMartin MatuskaThis usage is provided for compatibility with historical implementations.
42caf54c4fSMartin MatuskaSee COMPATIBILITY below for details.
43caf54c4fSMartin Matuska.Pp
44caf54c4fSMartin MatuskaThe other synopsis forms show the preferred usage.
45caf54c4fSMartin MatuskaThe first option to
46caf54c4fSMartin Matuska.Nm
47caf54c4fSMartin Matuskais a mode indicator from the following list:
48caf54c4fSMartin Matuska.Bl -tag -compact -width indent
49caf54c4fSMartin Matuska.It Fl c
50caf54c4fSMartin MatuskaCreate a new archive containing the specified items.
51c5d360f8SMartin MatuskaThe long option form is
52c5d360f8SMartin Matuska.Fl Fl create .
53caf54c4fSMartin Matuska.It Fl r
54caf54c4fSMartin MatuskaLike
55caf54c4fSMartin Matuska.Fl c ,
56caf54c4fSMartin Matuskabut new entries are appended to the archive.
57caf54c4fSMartin MatuskaNote that this only works on uncompressed archives stored in regular files.
58caf54c4fSMartin MatuskaThe
59caf54c4fSMartin Matuska.Fl f
60caf54c4fSMartin Matuskaoption is required.
61c5d360f8SMartin MatuskaThe long option form is
62c5d360f8SMartin Matuska.Fl Fl append .
63caf54c4fSMartin Matuska.It Fl t
64caf54c4fSMartin MatuskaList archive contents to stdout.
65c5d360f8SMartin MatuskaThe long option form is
66c5d360f8SMartin Matuska.Fl Fl list .
67caf54c4fSMartin Matuska.It Fl u
68caf54c4fSMartin MatuskaLike
69caf54c4fSMartin Matuska.Fl r ,
70caf54c4fSMartin Matuskabut new entries are added only if they have a modification date
71caf54c4fSMartin Matuskanewer than the corresponding entry in the archive.
72caf54c4fSMartin MatuskaNote that this only works on uncompressed archives stored in regular files.
73caf54c4fSMartin MatuskaThe
74caf54c4fSMartin Matuska.Fl f
75caf54c4fSMartin Matuskaoption is required.
76c5d360f8SMartin MatuskaThe long form is
77c5d360f8SMartin Matuska.Fl Fl update .
78caf54c4fSMartin Matuska.It Fl x
79caf54c4fSMartin MatuskaExtract to disk from the archive.
80caf54c4fSMartin MatuskaIf a file with the same name appears more than once in the archive,
81caf54c4fSMartin Matuskaeach copy will be extracted, with later copies overwriting (replacing)
82caf54c4fSMartin Matuskaearlier copies.
83c5d360f8SMartin MatuskaThe long option form is
84c5d360f8SMartin Matuska.Fl Fl extract .
85caf54c4fSMartin Matuska.El
86caf54c4fSMartin Matuska.Pp
87caf54c4fSMartin MatuskaIn
88caf54c4fSMartin Matuska.Fl c ,
89caf54c4fSMartin Matuska.Fl r ,
90caf54c4fSMartin Matuskaor
91caf54c4fSMartin Matuska.Fl u
92caf54c4fSMartin Matuskamode, each specified file or directory is added to the
93caf54c4fSMartin Matuskaarchive in the order specified on the command line.
94caf54c4fSMartin MatuskaBy default, the contents of each directory are also archived.
95caf54c4fSMartin Matuska.Pp
96caf54c4fSMartin MatuskaIn extract or list mode, the entire command line
97caf54c4fSMartin Matuskais read and parsed before the archive is opened.
98caf54c4fSMartin MatuskaThe pathnames or patterns on the command line indicate
99caf54c4fSMartin Matuskawhich items in the archive should be processed.
100caf54c4fSMartin MatuskaPatterns are shell-style globbing patterns as
101caf54c4fSMartin Matuskadocumented in
102caf54c4fSMartin Matuska.Xr tcsh 1 .
103caf54c4fSMartin Matuska.Sh OPTIONS
104caf54c4fSMartin MatuskaUnless specifically stated otherwise, options are applicable in
105caf54c4fSMartin Matuskaall operating modes.
106caf54c4fSMartin Matuska.Bl -tag -width indent
107caf54c4fSMartin Matuska.It Cm @ Ns Pa archive
10864287048SMartin Matuska(c and r modes only)
109caf54c4fSMartin MatuskaThe specified archive is opened and the entries
110caf54c4fSMartin Matuskain it will be appended to the current archive.
111caf54c4fSMartin MatuskaAs a simple example,
112caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar
113caf54c4fSMartin Matuskawrites a new archive to standard output containing a file
114caf54c4fSMartin Matuska.Pa newfile
115caf54c4fSMartin Matuskaand all of the entries from
116caf54c4fSMartin Matuska.Pa original.tar .
117caf54c4fSMartin MatuskaIn contrast,
118caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar
119caf54c4fSMartin Matuskacreates a new archive with only two entries.
120caf54c4fSMartin MatuskaSimilarly,
121c5d360f8SMartin Matuska.Dl Nm Fl czf Pa - Fl Fl format Cm pax Cm @ Ns Pa -
122caf54c4fSMartin Matuskareads an archive from standard input (whose format will be determined
123caf54c4fSMartin Matuskaautomatically) and converts it into a gzip-compressed
124caf54c4fSMartin Matuskapax-format archive on stdout.
125caf54c4fSMartin MatuskaIn this way,
126caf54c4fSMartin Matuska.Nm
127caf54c4fSMartin Matuskacan be used to convert archives from one format to another.
128acc60b03SMartin Matuska.It Fl a , Fl Fl auto-compress
129acc60b03SMartin Matuska(c mode only)
130acc60b03SMartin MatuskaUse the archive suffix to decide a set of the format and
131acc60b03SMartin Matuskathe compressions.
132acc60b03SMartin MatuskaAs a simple example,
133acc60b03SMartin Matuska.Dl Nm Fl a Fl cf Pa archive.tgz source.c source.h
134acc60b03SMartin Matuskacreates a new archive with restricted pax format and gzip compression,
135acc60b03SMartin Matuska.Dl Nm Fl a Fl cf Pa archive.tar.bz2.uu source.c source.h
136acc60b03SMartin Matuskacreates a new archive with restricted pax format and bzip2 compression
137acc60b03SMartin Matuskaand uuencode compression,
138acc60b03SMartin Matuska.Dl Nm Fl a Fl cf Pa archive.zip source.c source.h
139acc60b03SMartin Matuskacreates a new archive with zip format,
140acc60b03SMartin Matuska.Dl Nm Fl a Fl jcf Pa archive.tgz source.c source.h
141acc60b03SMartin Matuskaignores the
142acc60b03SMartin Matuska.Dq -j
143acc60b03SMartin Matuskaoption, and creates a new archive with restricted pax format
144acc60b03SMartin Matuskaand gzip compression,
145acc60b03SMartin Matuska.Dl Nm Fl a Fl jcf Pa archive.xxx source.c source.h
146acc60b03SMartin Matuskaif it is unknown suffix or no suffix, creates a new archive with
147acc60b03SMartin Matuskarestricted pax format and bzip2 compression.
14864287048SMartin Matuska.It Fl Fl acls
14964287048SMartin Matuska(c, r, u, x modes only)
150f057565eSMartin MatuskaArchive or extract POSIX.1e or NFSv4 ACLs.
151f057565eSMartin MatuskaThis is the reverse of
15264287048SMartin Matuska.Fl Fl no-acls
153e46d4714SMartin Matuskaand the default behavior in c, r, and u modes (except on Mac OS X) or if
15464287048SMartin Matuska.Nm
155f057565eSMartin Matuskais run in x mode as root.
156f057565eSMartin MatuskaOn Mac OS X this option translates extended ACLs to NFSv4 ACLs.
157f057565eSMartin MatuskaTo store extended ACLs the
15864287048SMartin Matuska.Fl Fl mac-metadata
15964287048SMartin Matuskaoption is preferred.
160c5d360f8SMartin Matuska.It Fl B , Fl Fl read-full-blocks
161c5d360f8SMartin MatuskaIgnored for compatibility with other
162c5d360f8SMartin Matuska.Xr tar 1
163c5d360f8SMartin Matuskaimplementations.
164c5d360f8SMartin Matuska.It Fl b Ar blocksize , Fl Fl block-size Ar blocksize
165caf54c4fSMartin MatuskaSpecify the block size, in 512-byte records, for tape drive I/O.
166caf54c4fSMartin MatuskaAs a rule, this argument is only needed when reading from or writing
167caf54c4fSMartin Matuskato tape drives, and usually not even then as the default block size of
168caf54c4fSMartin Matuska20 records (10240 bytes) is very common.
1696c95142eSMartin Matuska.It Fl C Ar directory , Fl Fl cd Ar directory , Fl Fl directory Ar directory
170caf54c4fSMartin MatuskaIn c and r mode, this changes the directory before adding
171caf54c4fSMartin Matuskathe following files.
172caf54c4fSMartin MatuskaIn x mode, change directories after opening the archive
173caf54c4fSMartin Matuskabut before extracting entries from the archive.
174c5d360f8SMartin Matuska.It Fl Fl chroot
175caf54c4fSMartin Matuska(x mode only)
176caf54c4fSMartin Matuska.Fn chroot
177caf54c4fSMartin Matuskato the current directory after processing any
178caf54c4fSMartin Matuska.Fl C
179caf54c4fSMartin Matuskaoptions and before extracting any files.
180cdf63a70SMartin Matuska.It Fl Fl clear-nochange-fflags
181cdf63a70SMartin Matuska(x mode only)
182cdf63a70SMartin MatuskaBefore removing file system objects to replace them, clear platform-specific
183fae5c36eSMartin Matuskafile attributes or file flags that might prevent removal.
184c5d360f8SMartin Matuska.It Fl Fl exclude Ar pattern
185caf54c4fSMartin MatuskaDo not process files or directories that match the
186caf54c4fSMartin Matuskaspecified pattern.
187caf54c4fSMartin MatuskaNote that exclusions take precedence over patterns or filenames
188caf54c4fSMartin Matuskaspecified on the command line.
18952c2bb75SMartin Matuska.It Fl Fl exclude-vcs
19052c2bb75SMartin MatuskaDo not process files or directories internally used by the
19152c2bb75SMartin Matuskaversion control systems
19252c2bb75SMartin Matuska.Sq Arch ,
19352c2bb75SMartin Matuska.Sq Bazaar ,
194f9762417SMartin Matuska.Sq CVS ,
195f9762417SMartin Matuska.Sq Darcs ,
196f9762417SMartin Matuska.Sq Mercurial ,
197f9762417SMartin Matuska.Sq RCS ,
198f9762417SMartin Matuska.Sq SCCS ,
199f9762417SMartin Matuska.Sq SVN
20052c2bb75SMartin Matuskaand
201f9762417SMartin Matuska.Sq git .
20264287048SMartin Matuska.It Fl Fl fflags
20364287048SMartin Matuska(c, r, u, x modes only)
204fae5c36eSMartin MatuskaArchive or extract platform-specific file attributes or file flags.
205fae5c36eSMartin MatuskaThis is the reverse of
20664287048SMartin Matuska.Fl Fl no-fflags
20764287048SMartin Matuskaand the default behavior in c, r, and u modes or if
20864287048SMartin Matuska.Nm
20964287048SMartin Matuskais run in x mode as root.
210c5d360f8SMartin Matuska.It Fl Fl format Ar format
211caf54c4fSMartin Matuska(c, r, u mode only)
212caf54c4fSMartin MatuskaUse the specified format for the created archive.
213caf54c4fSMartin MatuskaSupported formats include
214caf54c4fSMartin Matuska.Dq cpio ,
215caf54c4fSMartin Matuska.Dq pax ,
216caf54c4fSMartin Matuska.Dq shar ,
217caf54c4fSMartin Matuskaand
218caf54c4fSMartin Matuska.Dq ustar .
219caf54c4fSMartin MatuskaOther formats may also be supported; see
220caf54c4fSMartin Matuska.Xr libarchive-formats 5
221caf54c4fSMartin Matuskafor more information about currently-supported formats.
222caf54c4fSMartin MatuskaIn r and u modes, when extending an existing archive, the format specified
223caf54c4fSMartin Matuskahere must be compatible with the format of the existing archive on disk.
224c5d360f8SMartin Matuska.It Fl f Ar file , Fl Fl file Ar file
225caf54c4fSMartin MatuskaRead the archive from or write the archive to the specified file.
226caf54c4fSMartin MatuskaThe filename can be
227caf54c4fSMartin Matuska.Pa -
228caf54c4fSMartin Matuskafor standard input or standard output.
229c5d360f8SMartin MatuskaThe default varies by system;
230c5d360f8SMartin Matuskaon
231caf54c4fSMartin Matuska.Fx ,
232c5d360f8SMartin Matuskathe default is
233c5d360f8SMartin Matuska.Pa /dev/sa0 ;
234c5d360f8SMartin Matuskaon Linux, the default is
235c5d360f8SMartin Matuska.Pa /dev/st0 .
236caf54c4fSMartin Matuska.It Fl Fl gid Ar id
237caf54c4fSMartin MatuskaUse the provided group id number.
238caf54c4fSMartin MatuskaOn extract, this overrides the group id in the archive;
239caf54c4fSMartin Matuskathe group name in the archive will be ignored.
240caf54c4fSMartin MatuskaOn create, this overrides the group id read from disk;
241caf54c4fSMartin Matuskaif
242caf54c4fSMartin Matuska.Fl Fl gname
243caf54c4fSMartin Matuskais not also specified, the group name will be set to
244caf54c4fSMartin Matuskamatch the group id.
245caf54c4fSMartin Matuska.It Fl Fl gname Ar name
246caf54c4fSMartin MatuskaUse the provided group name.
247caf54c4fSMartin MatuskaOn extract, this overrides the group name in the archive;
248caf54c4fSMartin Matuskaif the provided group name does not exist on the system,
249caf54c4fSMartin Matuskathe group id
250caf54c4fSMartin Matuska(from the archive or from the
251caf54c4fSMartin Matuska.Fl Fl gid
252caf54c4fSMartin Matuskaoption)
253caf54c4fSMartin Matuskawill be used instead.
254caf54c4fSMartin MatuskaOn create, this sets the group name that will be stored
255caf54c4fSMartin Matuskain the archive;
256caf54c4fSMartin Matuskathe name will not be verified against the system group database.
257b9128a37SMartin Matuska.It Fl Fl group Ar name Ns Op : Ns Ar gid
258b9128a37SMartin MatuskaUse the provided group, if
259b9128a37SMartin Matuska.Ar gid
260b9128a37SMartin Matuskais not provided,
261b9128a37SMartin Matuska.Ar name
262b9128a37SMartin Matuskacan be either a group name or numeric id.
263b9128a37SMartin MatuskaSee the
264b9128a37SMartin Matuska.Fl Fl gname
265b9128a37SMartin Matuskaoption for details.
266caf54c4fSMartin Matuska.It Fl H
26764287048SMartin Matuska(c and r modes only)
268caf54c4fSMartin MatuskaSymbolic links named on the command line will be followed; the
269caf54c4fSMartin Matuskatarget of the link will be archived, not the link itself.
270caf54c4fSMartin Matuska.It Fl h
27164287048SMartin Matuska(c and r modes only)
272caf54c4fSMartin MatuskaSynonym for
273caf54c4fSMartin Matuska.Fl L .
274caf54c4fSMartin Matuska.It Fl I
275caf54c4fSMartin MatuskaSynonym for
276caf54c4fSMartin Matuska.Fl T .
277c5d360f8SMartin Matuska.It Fl Fl help
278c5d360f8SMartin MatuskaShow usage.
279acc60b03SMartin Matuska.It Fl Fl hfsCompression
280acc60b03SMartin Matuska(x mode only)
28164287048SMartin MatuskaMac OS X specific (v10.6 or later). Compress extracted regular files with HFS+
28264287048SMartin Matuskacompression.
283cdf63a70SMartin Matuska.It Fl Fl ignore-zeros
284cdf63a70SMartin MatuskaAn alias of
285cdf63a70SMartin Matuska.Fl Fl options Cm read_concatenated_archives
286cdf63a70SMartin Matuskafor compatibility with GNU tar.
287c5d360f8SMartin Matuska.It Fl Fl include Ar pattern
288caf54c4fSMartin MatuskaProcess only files or directories that match the specified pattern.
289caf54c4fSMartin MatuskaNote that exclusions specified with
290c5d360f8SMartin Matuska.Fl Fl exclude
291caf54c4fSMartin Matuskatake precedence over inclusions.
292caf54c4fSMartin MatuskaIf no inclusions are explicitly specified, all entries are processed by
293caf54c4fSMartin Matuskadefault.
294caf54c4fSMartin MatuskaThe
295c5d360f8SMartin Matuska.Fl Fl include
296caf54c4fSMartin Matuskaoption is especially useful when filtering archives.
297caf54c4fSMartin MatuskaFor example, the command
298c5d360f8SMartin Matuska.Dl Nm Fl c Fl f Pa new.tar Fl Fl include='*foo*' Cm @ Ns Pa old.tgz
299caf54c4fSMartin Matuskacreates a new archive
300caf54c4fSMartin Matuska.Pa new.tar
301caf54c4fSMartin Matuskacontaining only the entries from
302caf54c4fSMartin Matuska.Pa old.tgz
303caf54c4fSMartin Matuskacontaining the string
304caf54c4fSMartin Matuska.Sq foo .
305c5d360f8SMartin Matuska.It Fl J , Fl Fl xz
306c5d360f8SMartin Matuska(c mode only)
307c5d360f8SMartin MatuskaCompress the resulting archive with
308c5d360f8SMartin Matuska.Xr xz 1 .
309c5d360f8SMartin MatuskaIn extract or list modes, this option is ignored.
3105c831a5bSMartin MatuskaNote that this
311c5d360f8SMartin Matuska.Nm tar
3125c831a5bSMartin Matuskaimplementation recognizes XZ compression automatically when reading archives.
313c5d360f8SMartin Matuska.It Fl j , Fl Fl bzip , Fl Fl bzip2 , Fl Fl bunzip2
314caf54c4fSMartin Matuska(c mode only)
315caf54c4fSMartin MatuskaCompress the resulting archive with
316caf54c4fSMartin Matuska.Xr bzip2 1 .
317caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored.
3185c831a5bSMartin MatuskaNote that this
319caf54c4fSMartin Matuska.Nm tar
3205c831a5bSMartin Matuskaimplementation recognizes bzip2 compression automatically when reading
3215c831a5bSMartin Matuskaarchives.
322c5d360f8SMartin Matuska.It Fl k , Fl Fl keep-old-files
323caf54c4fSMartin Matuska(x mode only)
324caf54c4fSMartin MatuskaDo not overwrite existing files.
325caf54c4fSMartin MatuskaIn particular, if a file appears more than once in an archive,
326caf54c4fSMartin Matuskalater copies will not overwrite earlier copies.
327c5d360f8SMartin Matuska.It Fl Fl keep-newer-files
328caf54c4fSMartin Matuska(x mode only)
329caf54c4fSMartin MatuskaDo not overwrite existing files that are newer than the
330caf54c4fSMartin Matuskaversions appearing in the archive being extracted.
331c5d360f8SMartin Matuska.It Fl L , Fl Fl dereference
33264287048SMartin Matuska(c and r modes only)
333caf54c4fSMartin MatuskaAll symbolic links will be followed.
334caf54c4fSMartin MatuskaNormally, symbolic links are archived as such.
335caf54c4fSMartin MatuskaWith this option, the target of the link will be archived instead.
336c5d360f8SMartin Matuska.It Fl l , Fl Fl check-links
337c5d360f8SMartin Matuska(c and r modes only)
338c5d360f8SMartin MatuskaIssue a warning message unless all links to each file are archived.
339acc60b03SMartin Matuska.It Fl Fl lrzip
340acc60b03SMartin Matuska(c mode only)
341acc60b03SMartin MatuskaCompress the resulting archive with
342acc60b03SMartin Matuska.Xr lrzip 1 .
343acc60b03SMartin MatuskaIn extract or list modes, this option is ignored.
3445c831a5bSMartin MatuskaNote that this
3455c831a5bSMartin Matuska.Nm tar
3465c831a5bSMartin Matuskaimplementation recognizes lrzip compression automatically when reading
3475c831a5bSMartin Matuskaarchives.
348cdf63a70SMartin Matuska.It Fl Fl lz4
349cdf63a70SMartin Matuska(c mode only)
350cdf63a70SMartin MatuskaCompress the archive with lz4-compatible compression before writing it.
3515c831a5bSMartin MatuskaIn extract or list modes, this option is ignored.
3525c831a5bSMartin MatuskaNote that this
3535c831a5bSMartin Matuska.Nm tar
3545c831a5bSMartin Matuskaimplementation recognizes lz4 compression automatically when reading archives.
3555c831a5bSMartin Matuska.It Fl Fl zstd
3565c831a5bSMartin Matuska(c mode only)
3575c831a5bSMartin MatuskaCompress the archive with zstd-compatible compression before writing it.
3585c831a5bSMartin MatuskaIn extract or list modes, this option is ignored.
3595c831a5bSMartin MatuskaNote that this
3605c831a5bSMartin Matuska.Nm tar
3615c831a5bSMartin Matuskaimplementation recognizes zstd compression automatically when reading archives.
362c5d360f8SMartin Matuska.It Fl Fl lzma
363c5d360f8SMartin Matuska(c mode only) Compress the resulting archive with the original LZMA algorithm.
3645c831a5bSMartin MatuskaIn extract or list modes, this option is ignored.
365c5d360f8SMartin MatuskaUse of this option is discouraged and new archives should be created with
366c5d360f8SMartin Matuska.Fl Fl xz
367c5d360f8SMartin Matuskainstead.
3685c831a5bSMartin MatuskaNote that this
369c5d360f8SMartin Matuska.Nm tar
3705c831a5bSMartin Matuskaimplementation recognizes LZMA compression automatically when reading archives.
371acc60b03SMartin Matuska.It Fl Fl lzop
372acc60b03SMartin Matuska(c mode only)
373acc60b03SMartin MatuskaCompress the resulting archive with
374acc60b03SMartin Matuska.Xr lzop 1 .
375acc60b03SMartin MatuskaIn extract or list modes, this option is ignored.
3765c831a5bSMartin MatuskaNote that this
3775c831a5bSMartin Matuska.Nm tar
3785c831a5bSMartin Matuskaimplementation recognizes LZO compression automatically when reading archives.
379c5d360f8SMartin Matuska.It Fl m , Fl Fl modification-time
380caf54c4fSMartin Matuska(x mode only)
381caf54c4fSMartin MatuskaDo not extract modification time.
382caf54c4fSMartin MatuskaBy default, the modification time is set to the time stored in the archive.
38364287048SMartin Matuska.It Fl Fl mac-metadata
38464287048SMartin Matuska(c, r, u and x mode only)
385f057565eSMartin MatuskaMac OS X specific.
386f057565eSMartin MatuskaArchive or extract extended ACLs and extended file
387fae5c36eSMartin Matuskaattributes using
38864287048SMartin Matuska.Xr copyfile 3
389f057565eSMartin Matuskain AppleDouble format.
390f057565eSMartin MatuskaThis is the reverse of
39164287048SMartin Matuska.Fl Fl no-mac-metadata .
39264287048SMartin Matuskaand the default behavior in c, r, and u modes or if
39364287048SMartin Matuska.Nm
39464287048SMartin Matuskais run in x mode as root.
395b9128a37SMartin MatuskaCurrently supported only for pax formats
396b9128a37SMartin Matuska(including "pax restricted", the default tar format for bsdtar.)
397c5d360f8SMartin Matuska.It Fl n , Fl Fl norecurse , Fl Fl no-recursion
39852c2bb75SMartin MatuskaDo not operate recursively on the content of directories.
399c5d360f8SMartin Matuska.It Fl Fl newer Ar date
400caf54c4fSMartin Matuska(c, r, u modes only)
401caf54c4fSMartin MatuskaOnly include files and directories newer than the specified date.
402caf54c4fSMartin MatuskaThis compares ctime entries.
403c5d360f8SMartin Matuska.It Fl Fl newer-mtime Ar date
404caf54c4fSMartin Matuska(c, r, u modes only)
405caf54c4fSMartin MatuskaLike
406c5d360f8SMartin Matuska.Fl Fl newer ,
407caf54c4fSMartin Matuskaexcept it compares mtime entries instead of ctime entries.
408c5d360f8SMartin Matuska.It Fl Fl newer-than Pa file
409caf54c4fSMartin Matuska(c, r, u modes only)
410caf54c4fSMartin MatuskaOnly include files and directories newer than the specified file.
411caf54c4fSMartin MatuskaThis compares ctime entries.
412c5d360f8SMartin Matuska.It Fl Fl newer-mtime-than Pa file
413caf54c4fSMartin Matuska(c, r, u modes only)
414caf54c4fSMartin MatuskaLike
415c5d360f8SMartin Matuska.Fl Fl newer-than ,
416caf54c4fSMartin Matuskaexcept it compares mtime entries instead of ctime entries.
417c5d360f8SMartin Matuska.It Fl Fl nodump
418caf54c4fSMartin Matuska(c and r modes only)
419caf54c4fSMartin MatuskaHonor the nodump file flag by skipping this file.
420acc60b03SMartin Matuska.It Fl Fl nopreserveHFSCompression
421acc60b03SMartin Matuska(x mode only)
422acc60b03SMartin MatuskaMac OS X specific (v10.6 or later). Do not compress extracted regular files
423acc60b03SMartin Matuskawhich were compressed with HFS+ compression before archived.
424acc60b03SMartin MatuskaBy default, compress the regular files again with HFS+ compression.
425c5d360f8SMartin Matuska.It Fl Fl null
426caf54c4fSMartin Matuska(use with
427c5d360f8SMartin Matuska.Fl I
428caf54c4fSMartin Matuskaor
429c5d360f8SMartin Matuska.Fl T )
430caf54c4fSMartin MatuskaFilenames or patterns are separated by null characters,
431caf54c4fSMartin Matuskanot by newlines.
432caf54c4fSMartin MatuskaThis is often used to read filenames output by the
433caf54c4fSMartin Matuska.Fl print0
434caf54c4fSMartin Matuskaoption to
435caf54c4fSMartin Matuska.Xr find 1 .
43664287048SMartin Matuska.It Fl Fl no-acls
43764287048SMartin Matuska(c, r, u, x modes only)
438f057565eSMartin MatuskaDo not archive or extract POSIX.1e or NFSv4 ACLs.
439f057565eSMartin MatuskaThis is the reverse of
44064287048SMartin Matuska.Fl Fl acls
44164287048SMartin Matuskaand the default behavior if
44264287048SMartin Matuska.Nm
443e46d4714SMartin Matuskais run as non-root in x mode (on Mac OS X as any user in c, r, u and x modes).
44464287048SMartin Matuska.It Fl Fl no-fflags
44564287048SMartin Matuska(c, r, u, x modes only)
446f057565eSMartin MatuskaDo not archive or extract file attributes or file flags.
447f057565eSMartin MatuskaThis is the reverse of
44864287048SMartin Matuska.Fl Fl fflags
44964287048SMartin Matuskaand the default behavior if
45064287048SMartin Matuska.Nm
45164287048SMartin Matuskais run as non-root in x mode.
45264287048SMartin Matuska.It Fl Fl no-mac-metadata
45364287048SMartin Matuska(x mode only)
454f057565eSMartin MatuskaMac OS X specific.
455f057565eSMartin MatuskaDo not archive or extract ACLs and extended file attributes
456fae5c36eSMartin Matuskausing
45764287048SMartin Matuska.Xr copyfile 3
458f057565eSMartin Matuskain AppleDouble format.
459f057565eSMartin MatuskaThis is the reverse of
46064287048SMartin Matuska.Fl Fl mac-metadata .
46164287048SMartin Matuskaand the default behavior if
46264287048SMartin Matuska.Nm
46364287048SMartin Matuskais run as non-root in x mode.
464833a452eSMartin Matuska.It Fl Fl no-read-sparse
465833a452eSMartin Matuska(c, r, u modes only)
466833a452eSMartin MatuskaDo not read sparse file information from disk.
467833a452eSMartin MatuskaThis is the reverse of
468833a452eSMartin Matuska.Fl Fl read-sparse .
469f9762417SMartin Matuska.It Fl Fl no-safe-writes
470f9762417SMartin Matuska(x mode only)
471f9762417SMartin MatuskaDo not create temporary files and use
472f9762417SMartin Matuska.Xr rename 2
473f9762417SMartin Matuskato replace the original ones.
474f9762417SMartin MatuskaThis is the reverse of
475f9762417SMartin Matuska.Fl Fl safe-writes .
476caf54c4fSMartin Matuska.It Fl Fl no-same-owner
477caf54c4fSMartin Matuska(x mode only)
478caf54c4fSMartin MatuskaDo not extract owner and group IDs.
479caf54c4fSMartin MatuskaThis is the reverse of
480caf54c4fSMartin Matuska.Fl Fl same-owner
481caf54c4fSMartin Matuskaand the default behavior if
482caf54c4fSMartin Matuska.Nm
483caf54c4fSMartin Matuskais run as non-root.
484caf54c4fSMartin Matuska.It Fl Fl no-same-permissions
485caf54c4fSMartin Matuska(x mode only)
486fae5c36eSMartin MatuskaDo not extract full permissions (SGID, SUID, sticky bit,
487fae5c36eSMartin Matuskafile attributes or file flags, extended file attributes and ACLs).
488caf54c4fSMartin MatuskaThis is the reverse of
489caf54c4fSMartin Matuska.Fl p
490caf54c4fSMartin Matuskaand the default behavior if
491caf54c4fSMartin Matuska.Nm
492caf54c4fSMartin Matuskais run as non-root.
49364287048SMartin Matuska.It Fl Fl no-xattrs
49464287048SMartin Matuska(c, r, u, x modes only)
495f057565eSMartin MatuskaDo not archive or extract extended file attributes.
496f057565eSMartin MatuskaThis is the reverse of
49764287048SMartin Matuska.Fl Fl xattrs
49864287048SMartin Matuskaand the default behavior if
49964287048SMartin Matuska.Nm
50064287048SMartin Matuskais run as non-root in x mode.
501caf54c4fSMartin Matuska.It Fl Fl numeric-owner
502caf54c4fSMartin MatuskaThis is equivalent to
503caf54c4fSMartin Matuska.Fl Fl uname
504caf54c4fSMartin Matuska.Qq
505caf54c4fSMartin Matuska.Fl Fl gname
506caf54c4fSMartin Matuska.Qq .
507caf54c4fSMartin MatuskaOn extract, it causes user and group names in the archive
508caf54c4fSMartin Matuskato be ignored in favor of the numeric user and group ids.
509caf54c4fSMartin MatuskaOn create, it causes user and group names to not be stored
510caf54c4fSMartin Matuskain the archive.
511c5d360f8SMartin Matuska.It Fl O , Fl Fl to-stdout
512caf54c4fSMartin Matuska(x, t modes only)
513caf54c4fSMartin MatuskaIn extract (-x) mode, files will be written to standard out rather than
514caf54c4fSMartin Matuskabeing extracted to disk.
515caf54c4fSMartin MatuskaIn list (-t) mode, the file listing will be written to stderr rather than
516caf54c4fSMartin Matuskathe usual stdout.
517caf54c4fSMartin Matuska.It Fl o
518caf54c4fSMartin Matuska(x mode)
519caf54c4fSMartin MatuskaUse the user and group of the user running the program rather
520caf54c4fSMartin Matuskathan those specified in the archive.
521caf54c4fSMartin MatuskaNote that this has no significance unless
522caf54c4fSMartin Matuska.Fl p
523caf54c4fSMartin Matuskais specified, and the program is being run by the root user.
524caf54c4fSMartin MatuskaIn this case, the file modes and flags from
525caf54c4fSMartin Matuskathe archive will be restored, but ACLs or owner information in
526caf54c4fSMartin Matuskathe archive will be discarded.
527caf54c4fSMartin Matuska.It Fl o
528caf54c4fSMartin Matuska(c, r, u mode)
529caf54c4fSMartin MatuskaA synonym for
530c5d360f8SMartin Matuska.Fl Fl format Ar ustar
531acc60b03SMartin Matuska.It Fl Fl older Ar date
532acc60b03SMartin Matuska(c, r, u modes only)
533acc60b03SMartin MatuskaOnly include files and directories older than the specified date.
534acc60b03SMartin MatuskaThis compares ctime entries.
535acc60b03SMartin Matuska.It Fl Fl older-mtime Ar date
536acc60b03SMartin Matuska(c, r, u modes only)
537acc60b03SMartin MatuskaLike
538acc60b03SMartin Matuska.Fl Fl older ,
539acc60b03SMartin Matuskaexcept it compares mtime entries instead of ctime entries.
540acc60b03SMartin Matuska.It Fl Fl older-than Pa file
541acc60b03SMartin Matuska(c, r, u modes only)
542acc60b03SMartin MatuskaOnly include files and directories older than the specified file.
543acc60b03SMartin MatuskaThis compares ctime entries.
544acc60b03SMartin Matuska.It Fl Fl older-mtime-than Pa file
545acc60b03SMartin Matuska(c, r, u modes only)
546acc60b03SMartin MatuskaLike
547acc60b03SMartin Matuska.Fl Fl older-than ,
548acc60b03SMartin Matuskaexcept it compares mtime entries instead of ctime entries.
549c5d360f8SMartin Matuska.It Fl Fl one-file-system
550caf54c4fSMartin Matuska(c, r, and u modes)
551caf54c4fSMartin MatuskaDo not cross mount points.
552c5d360f8SMartin Matuska.It Fl Fl options Ar options
553caf54c4fSMartin MatuskaSelect optional behaviors for particular modules.
554caf54c4fSMartin MatuskaThe argument is a text string containing comma-separated
555caf54c4fSMartin Matuskakeywords and values.
556caf54c4fSMartin MatuskaThese are passed to the modules that handle particular
557caf54c4fSMartin Matuskaformats to control how those formats will behave.
558caf54c4fSMartin MatuskaEach option has one of the following forms:
559caf54c4fSMartin Matuska.Bl -tag -compact -width indent
560caf54c4fSMartin Matuska.It Ar key=value
561caf54c4fSMartin MatuskaThe key will be set to the specified value in every module that supports it.
562caf54c4fSMartin MatuskaModules that do not support this key will ignore it.
563caf54c4fSMartin Matuska.It Ar key
564caf54c4fSMartin MatuskaThe key will be enabled in every module that supports it.
565caf54c4fSMartin MatuskaThis is equivalent to
566caf54c4fSMartin Matuska.Ar key Ns Cm =1 .
567caf54c4fSMartin Matuska.It Ar !key
568caf54c4fSMartin MatuskaThe key will be disabled in every module that supports it.
569caf54c4fSMartin Matuska.It Ar module:key=value , Ar module:key , Ar module:!key
570caf54c4fSMartin MatuskaAs above, but the corresponding key and value will be provided
571caf54c4fSMartin Matuskaonly to modules whose name matches
572caf54c4fSMartin Matuska.Ar module .
573caf54c4fSMartin Matuska.El
574f9762417SMartin Matuska.Pp
575f9762417SMartin MatuskaThe complete list of supported modules and keys
576f9762417SMartin Matuskafor create and append modes is in
577f9762417SMartin Matuska.Xr archive_write_set_options 3
578f9762417SMartin Matuskaand for extract and list modes in
579f9762417SMartin Matuska.Xr archive_read_set_options 3 .
580f9762417SMartin Matuska.Pp
581f9762417SMartin MatuskaExamples of supported options:
582caf54c4fSMartin Matuska.Bl -tag -compact -width indent
583caf54c4fSMartin Matuska.It Cm iso9660:joliet
584caf54c4fSMartin MatuskaSupport Joliet extensions.
585caf54c4fSMartin MatuskaThis is enabled by default, use
586caf54c4fSMartin Matuska.Cm !joliet
587caf54c4fSMartin Matuskaor
588caf54c4fSMartin Matuska.Cm iso9660:!joliet
589caf54c4fSMartin Matuskato disable.
590caf54c4fSMartin Matuska.It Cm iso9660:rockridge
591caf54c4fSMartin MatuskaSupport Rock Ridge extensions.
592caf54c4fSMartin MatuskaThis is enabled by default, use
593caf54c4fSMartin Matuska.Cm !rockridge
594caf54c4fSMartin Matuskaor
595caf54c4fSMartin Matuska.Cm iso9660:!rockridge
596caf54c4fSMartin Matuskato disable.
597caf54c4fSMartin Matuska.It Cm gzip:compression-level
598acc60b03SMartin MatuskaA decimal integer from 1 to 9 specifying the gzip compression level.
599acc60b03SMartin Matuska.It Cm gzip:timestamp
600f057565eSMartin MatuskaStore timestamp.
601f057565eSMartin MatuskaThis is enabled by default, use
602acc60b03SMartin Matuska.Cm !timestamp
603acc60b03SMartin Matuskaor
604acc60b03SMartin Matuska.Cm gzip:!timestamp
605acc60b03SMartin Matuskato disable.
606acc60b03SMartin Matuska.It Cm lrzip:compression Ns = Ns Ar type
607acc60b03SMartin MatuskaUse
608acc60b03SMartin Matuska.Ar type
609acc60b03SMartin Matuskaas compression method.
610acc60b03SMartin MatuskaSupported values are bzip2, gzip, lzo (ultra fast),
611acc60b03SMartin Matuskaand zpaq (best, extremely slow).
612acc60b03SMartin Matuska.It Cm lrzip:compression-level
613acc60b03SMartin MatuskaA decimal integer from 1 to 9 specifying the lrzip compression level.
614cdf63a70SMartin Matuska.It Cm lz4:compression-level
615cdf63a70SMartin MatuskaA decimal integer from 1 to 9 specifying the lzop compression level.
616cdf63a70SMartin Matuska.It Cm lz4:stream-checksum
617f057565eSMartin MatuskaEnable stream checksum.
618f057565eSMartin MatuskaThis is by default, use
619cdf63a70SMartin Matuska.Cm lz4:!stream-checksum
620cdf63a70SMartin Matuskato disable.
621cdf63a70SMartin Matuska.It Cm lz4:block-checksum
622cdf63a70SMartin MatuskaEnable block checksum (Disabled by default).
623cdf63a70SMartin Matuska.It Cm lz4:block-size
624cdf63a70SMartin MatuskaA decimal integer from 4 to 7 specifying the lz4 compression block size
625cdf63a70SMartin Matuska(7 is set by default).
626cdf63a70SMartin Matuska.It Cm lz4:block-dependence
627cdf63a70SMartin MatuskaUse the previous block of the block being compressed for
628cdf63a70SMartin Matuskaa compression dictionary to improve compression ratio.
62913d826ffSMartin Matuska.It Cm zstd:compression-level Ns = Ns Ar N
63013d826ffSMartin MatuskaA decimal integer specifying the zstd compression level.
63113d826ffSMartin MatuskaSupported values depend
632de6fa6b4SMartin Matuskaon the library version, common values are from 1 to 22.
63313d826ffSMartin Matuska.It Cm zstd:threads Ns = Ns Ar N
63413d826ffSMartin MatuskaSpecify the number of worker threads to use, or 0 to use as many
63513d826ffSMartin Matuskathreads as there are CPU cores in the system.
636e64fe029SMartin Matuska.It Cm zstd:frame-per-file
637e64fe029SMartin MatuskaStart a new compression frame at the beginning of each file in the
638e64fe029SMartin Matuskaarchive.
639b9128a37SMartin Matuska.It Cm zstd:min-frame-in Ns = Ns Ar N
640e64fe029SMartin MatuskaIn combination with
641e64fe029SMartin Matuska.Cm zstd:frame-per-file ,
642b9128a37SMartin Matuskado not start a new compression frame unless the uncompressed size of
643b9128a37SMartin Matuskathe current frame is at least
644e64fe029SMartin Matuska.Ar N
645e64fe029SMartin Matuskabytes.
646b9128a37SMartin MatuskaThe number may be followed by
647b9128a37SMartin Matuska.Li k / Li kB ,
648b9128a37SMartin Matuska.Li M / Li MB ,
649b9128a37SMartin Matuskaor
650b9128a37SMartin Matuska.Li G / Li GB
651b9128a37SMartin Matuskato indicate kilobytes, megabytes or gigabytes respectively.
652b9128a37SMartin Matuska.It Cm zstd:min-frame-out Ns = Ns Ar N , Cm zstd:min-frame-size Ns = Ns Ar N
653b9128a37SMartin MatuskaIn combination with
654b9128a37SMartin Matuska.Cm zstd:frame-per-file ,
655b9128a37SMartin Matuskado not start a new compression frame unless the compressed size of the
656b9128a37SMartin Matuskacurrent frame is at least
657e64fe029SMartin Matuska.Ar N
658e64fe029SMartin Matuskabytes.
659b9128a37SMartin MatuskaThe number may be followed by
660b9128a37SMartin Matuska.Li k / Li kB ,
661b9128a37SMartin Matuska.Li M / Li MB ,
662b9128a37SMartin Matuskaor
663b9128a37SMartin Matuska.Li G / Li GB
664b9128a37SMartin Matuskato indicate kilobytes, megabytes or gigabytes respectively.
665b9128a37SMartin Matuska.It Cm zstd:max-frame-in Ns = Ns Ar N , Cm zstd:max-frame-size Ns = Ns Ar N
666b9128a37SMartin MatuskaStart a new compression frame as soon as possible after the
667b9128a37SMartin Matuskauncompressed size of the current frame exceeds
668b9128a37SMartin Matuska.Ar N
669b9128a37SMartin Matuskabytes.
670b9128a37SMartin MatuskaThe number may be followed by
671b9128a37SMartin Matuska.Li k / Li kB ,
672b9128a37SMartin Matuska.Li M / Li MB ,
673b9128a37SMartin Matuskaor
674b9128a37SMartin Matuska.Li G / Li GB
675b9128a37SMartin Matuskato indicate kilobytes, megabytes or gigabytes respectively.
676b9128a37SMartin MatuskaValues less than 1,024 will be rejected.
677b9128a37SMartin Matuska.It Cm zstd:max-frame-out Ns = Ns Ar N
678b9128a37SMartin MatuskaStart a new compression frame as soon as possible after the compressed
679b9128a37SMartin Matuskasize of the current frame exceeds
680b9128a37SMartin Matuska.Ar N
681b9128a37SMartin Matuskabytes.
682b9128a37SMartin MatuskaThe number may be followed by
683b9128a37SMartin Matuska.Li k / Li kB ,
684b9128a37SMartin Matuska.Li M / Li MB ,
685b9128a37SMartin Matuskaor
686b9128a37SMartin Matuska.Li G / Li GB
687b9128a37SMartin Matuskato indicate kilobytes, megabytes or gigabytes respectively.
688b9128a37SMartin MatuskaValues less than 1,024 will be rejected.
689acc60b03SMartin Matuska.It Cm lzop:compression-level
690acc60b03SMartin MatuskaA decimal integer from 1 to 9 specifying the lzop compression level.
691caf54c4fSMartin Matuska.It Cm xz:compression-level
692caf54c4fSMartin MatuskaA decimal integer from 0 to 9 specifying the xz compression level.
693833a452eSMartin Matuska.It Cm xz:threads
694833a452eSMartin MatuskaSpecify the number of worker threads to use.
695833a452eSMartin MatuskaSetting threads to a special value 0 makes
696833a452eSMartin Matuska.Xr xz 1
697833a452eSMartin Matuskause as many threads as there are CPU cores on the system.
698caf54c4fSMartin Matuska.It Cm mtree: Ns Ar keyword
699caf54c4fSMartin MatuskaThe mtree writer module allows you to specify which mtree keywords
700caf54c4fSMartin Matuskawill be included in the output.
701caf54c4fSMartin MatuskaSupported keywords include:
702caf54c4fSMartin Matuska.Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent ,
703caf54c4fSMartin Matuska.Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 ,
704caf54c4fSMartin Matuska.Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname .
705caf54c4fSMartin MatuskaThe default is equivalent to:
706caf54c4fSMartin Matuska.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
707caf54c4fSMartin Matuska.It Cm mtree:all
708caf54c4fSMartin MatuskaEnables all of the above keywords.
709caf54c4fSMartin MatuskaYou can also use
710caf54c4fSMartin Matuska.Cm mtree:!all
711caf54c4fSMartin Matuskato disable all keywords.
712caf54c4fSMartin Matuska.It Cm mtree:use-set
713caf54c4fSMartin MatuskaEnable generation of
714caf54c4fSMartin Matuska.Cm /set
715caf54c4fSMartin Matuskalines in the output.
716caf54c4fSMartin Matuska.It Cm mtree:indent
717caf54c4fSMartin MatuskaProduce human-readable output by indenting options and splitting lines
718caf54c4fSMartin Matuskato fit into 80 columns.
719caf54c4fSMartin Matuska.It Cm zip:compression Ns = Ns Ar type
720caf54c4fSMartin MatuskaUse
721caf54c4fSMartin Matuska.Ar type
722caf54c4fSMartin Matuskaas compression method.
723caf54c4fSMartin MatuskaSupported values are store (uncompressed) and deflate (gzip algorithm).
724cdf63a70SMartin Matuska.It Cm zip:encryption
725cdf63a70SMartin MatuskaEnable encryption using traditional zip encryption.
726cdf63a70SMartin Matuska.It Cm zip:encryption Ns = Ns Ar type
727cdf63a70SMartin MatuskaUse
728cdf63a70SMartin Matuska.Ar type
729cdf63a70SMartin Matuskaas encryption type.
730cdf63a70SMartin MatuskaSupported values are zipcrypt (traditional zip encryption),
731cdf63a70SMartin Matuskaaes128 (WinZip AES-128 encryption) and aes256 (WinZip AES-256 encryption).
732cdf63a70SMartin Matuska.It Cm read_concatenated_archives
733cdf63a70SMartin MatuskaIgnore zeroed blocks in the archive, which occurs when multiple tar archives
734f057565eSMartin Matuskahave been concatenated together.
735f057565eSMartin MatuskaWithout this option, only the contents of
736f057565eSMartin Matuskathe first concatenated archive would be read.
737f057565eSMartin MatuskaThis option is comparable to the
738cdf63a70SMartin Matuska.Fl i , Fl Fl ignore-zeros
739cdf63a70SMartin Matuskaoption of GNU tar.
740caf54c4fSMartin Matuska.El
741caf54c4fSMartin MatuskaIf a provided option is not supported by any module, that
742caf54c4fSMartin Matuskais a fatal error.
743c5d360f8SMartin Matuska.It Fl P , Fl Fl absolute-paths
744caf54c4fSMartin MatuskaPreserve pathnames.
745caf54c4fSMartin MatuskaBy default, absolute pathnames (those that begin with a /
746caf54c4fSMartin Matuskacharacter) have the leading slash removed both when creating archives
747caf54c4fSMartin Matuskaand extracting from them.
748caf54c4fSMartin MatuskaAlso,
749caf54c4fSMartin Matuska.Nm
750caf54c4fSMartin Matuskawill refuse to extract archive entries whose pathnames contain
751caf54c4fSMartin Matuska.Pa ..
752caf54c4fSMartin Matuskaor whose target directory would be altered by a symlink.
753caf54c4fSMartin MatuskaThis option suppresses these behaviors.
754c5d360f8SMartin Matuska.It Fl p , Fl Fl insecure , Fl Fl preserve-permissions
755caf54c4fSMartin Matuska(x mode only)
756caf54c4fSMartin MatuskaPreserve file permissions.
757fae5c36eSMartin MatuskaAttempt to restore the full permissions, including file modes, file attributes
758fae5c36eSMartin Matuskaor file flags, extended file attributes and ACLs, if available, for each item
759f057565eSMartin Matuskaextracted from the archive.
760f057565eSMartin MatuskaThis is the reverse of
76164287048SMartin Matuska.Fl Fl no-same-permissions
76264287048SMartin Matuskaand the default if
763caf54c4fSMartin Matuska.Nm
764f057565eSMartin Matuskais being run as root.
765f057565eSMartin MatuskaIt can be partially overridden by also specifying
76664287048SMartin Matuska.Fl Fl no-acls ,
76764287048SMartin Matuska.Fl Fl no-fflags ,
76864287048SMartin Matuska.Fl Fl no-mac-metadata
76964287048SMartin Matuskaor
77064287048SMartin Matuska.Fl Fl no-xattrs .
771cdf63a70SMartin Matuska.It Fl Fl passphrase Ar passphrase
772cdf63a70SMartin MatuskaThe
773cdf63a70SMartin Matuska.Pa passphrase
774cdf63a70SMartin Matuskais used to extract or create an encrypted archive.
775cdf63a70SMartin MatuskaCurrently, zip is the only supported format that supports encryption.
776cdf63a70SMartin MatuskaYou shouldn't use this option unless you realize how insecure
777cdf63a70SMartin Matuskause of this option is.
778c5d360f8SMartin Matuska.It Fl Fl posix
779c5d360f8SMartin Matuska(c, r, u mode only)
780c5d360f8SMartin MatuskaSynonym for
781c5d360f8SMartin Matuska.Fl Fl format Ar pax
782c5d360f8SMartin Matuska.It Fl q , Fl Fl fast-read
783caf54c4fSMartin Matuska(x and t mode only)
784caf54c4fSMartin MatuskaExtract or list only the first archive entry that matches each pattern
785caf54c4fSMartin Matuskaor filename operand.
786caf54c4fSMartin MatuskaExit as soon as each specified pattern or filename has been matched.
787caf54c4fSMartin MatuskaBy default, the archive is always read to the very end, since
788caf54c4fSMartin Matuskathere can be multiple entries with the same name and, by convention,
789caf54c4fSMartin Matuskalater entries overwrite earlier entries.
790caf54c4fSMartin MatuskaThis option is provided as a performance optimization.
791833a452eSMartin Matuska.It Fl Fl read-sparse
792833a452eSMartin Matuska(c, r, u modes only)
793833a452eSMartin MatuskaRead sparse file information from disk.
794833a452eSMartin MatuskaThis is the reverse of
795833a452eSMartin Matuska.Fl Fl no-read-sparse
796833a452eSMartin Matuskaand the default behavior.
797caf54c4fSMartin Matuska.It Fl S
798caf54c4fSMartin Matuska(x mode only)
799caf54c4fSMartin MatuskaExtract files as sparse files.
800caf54c4fSMartin MatuskaFor every block on disk, check first if it contains only NULL bytes and seek
801caf54c4fSMartin Matuskaover it otherwise.
802c5d360f8SMartin MatuskaThis works similar to the conv=sparse option of dd.
803caf54c4fSMartin Matuska.It Fl s Ar pattern
804caf54c4fSMartin MatuskaModify file or archive member names according to
805caf54c4fSMartin Matuska.Pa pattern .
806caf54c4fSMartin MatuskaThe pattern has the format
807b9128a37SMartin Matuska.Ar /old/new/ Ns Op bghHprRsS
808caf54c4fSMartin Matuskawhere
809caf54c4fSMartin Matuska.Ar old
810caf54c4fSMartin Matuskais a basic regular expression,
811caf54c4fSMartin Matuska.Ar new
812caf54c4fSMartin Matuskais the replacement string of the matched part,
813caf54c4fSMartin Matuskaand the optional trailing letters modify
814caf54c4fSMartin Matuskahow the replacement is handled.
815caf54c4fSMartin MatuskaIf
816caf54c4fSMartin Matuska.Ar old
817caf54c4fSMartin Matuskais not matched, the pattern is skipped.
818caf54c4fSMartin MatuskaWithin
819caf54c4fSMartin Matuska.Ar new ,
820caf54c4fSMartin Matuska~ is substituted with the match, \e1 to \e9 with the content of
821caf54c4fSMartin Matuskathe corresponding captured group.
822caf54c4fSMartin MatuskaThe optional trailing g specifies that matching should continue
8236c95142eSMartin Matuskaafter the matched part and stop on the first unmatched pattern.
824caf54c4fSMartin MatuskaThe optional trailing s specifies that the pattern applies to the value
825caf54c4fSMartin Matuskaof symbolic links.
826caf54c4fSMartin MatuskaThe optional trailing p specifies that after a successful substitution
827caf54c4fSMartin Matuskathe original path name and the new path name should be printed to
828caf54c4fSMartin Matuskastandard error.
829b9128a37SMartin MatuskaThe optional trailing b specifies that the substitution should be
830b9128a37SMartin Matuskamatched from the beginning of the string rather than from right after the
831b9128a37SMartin Matuskaposition at which the previous matching substitution ended.
8326c95142eSMartin MatuskaOptional trailing H, R, or S characters suppress substitutions
8336c95142eSMartin Matuskafor hardlink targets, regular filenames, or symlink targets,
8346c95142eSMartin Matuskarespectively.
8356c95142eSMartin MatuskaOptional trailing h, r, or s characters enable substitutions
8366c95142eSMartin Matuskafor hardlink targets, regular filenames, or symlink targets,
8376c95142eSMartin Matuskarespectively.
8386c95142eSMartin MatuskaThe default is
8396c95142eSMartin Matuska.Ar hrs
8406c95142eSMartin Matuskawhich applies substitutions to all names.
8416c95142eSMartin MatuskaIn particular, it is never necessary to specify h, r, or s.
842f9762417SMartin Matuska.It Fl Fl safe-writes
843f9762417SMartin Matuska(x mode only)
844f9762417SMartin MatuskaExtract files atomically.
845f9762417SMartin MatuskaBy default
846f9762417SMartin Matuska.Nm
847f9762417SMartin Matuskaunlinks the original file with the same name as the extracted file (if it
848f9762417SMartin Matuskaexists), and then creates it immediately under the same name and writes to
849f9762417SMartin Matuskait.
850f9762417SMartin MatuskaFor a short period of time, applications trying to access the file might
851f9762417SMartin Matuskanot find it, or see incomplete results.
852f9762417SMartin MatuskaIf
853f9762417SMartin Matuska.Fl Fl safe-writes
854f9762417SMartin Matuskais enabled,
855f9762417SMartin Matuska.Nm
856f9762417SMartin Matuskafirst creates a unique temporary file, then writes the new contents to
857f9762417SMartin Matuskathe temporary file, and finally renames the temporary file to its final
858f9762417SMartin Matuskaname atomically using
859f9762417SMartin Matuska.Xr rename 2 .
860f9762417SMartin MatuskaThis guarantees that an application accessing the file, will either see
861f9762417SMartin Matuskathe old contents or the new contents at all times.
8626c95142eSMartin Matuska.It Fl Fl same-owner
8636c95142eSMartin Matuska(x mode only)
8646c95142eSMartin MatuskaExtract owner and group IDs.
8656c95142eSMartin MatuskaThis is the reverse of
8666c95142eSMartin Matuska.Fl Fl no-same-owner
8676c95142eSMartin Matuskaand the default behavior if
8686c95142eSMartin Matuska.Nm
8696c95142eSMartin Matuskais run as root.
8706c95142eSMartin Matuska.It Fl Fl strip-components Ar count
8716c95142eSMartin MatuskaRemove the specified number of leading path elements.
8726c95142eSMartin MatuskaPathnames with fewer elements will be silently skipped.
8736c95142eSMartin MatuskaNote that the pathname is edited after checking inclusion/exclusion patterns
8746c95142eSMartin Matuskabut before security checks.
875c5d360f8SMartin Matuska.It Fl T Ar filename , Fl Fl files-from Ar filename
876caf54c4fSMartin MatuskaIn x or t mode,
877caf54c4fSMartin Matuska.Nm
878caf54c4fSMartin Matuskawill read the list of names to be extracted from
879caf54c4fSMartin Matuska.Pa filename .
880caf54c4fSMartin MatuskaIn c mode,
881caf54c4fSMartin Matuska.Nm
882caf54c4fSMartin Matuskawill read names to be archived from
883caf54c4fSMartin Matuska.Pa filename .
884caf54c4fSMartin MatuskaThe special name
885caf54c4fSMartin Matuska.Dq -C
886caf54c4fSMartin Matuskaon a line by itself will cause the current directory to be changed to
887caf54c4fSMartin Matuskathe directory specified on the following line.
888caf54c4fSMartin MatuskaNames are terminated by newlines unless
889c5d360f8SMartin Matuska.Fl Fl null
890caf54c4fSMartin Matuskais specified.
891caf54c4fSMartin MatuskaNote that
892c5d360f8SMartin Matuska.Fl Fl null
893caf54c4fSMartin Matuskaalso disables the special handling of lines containing
894caf54c4fSMartin Matuska.Dq -C .
895acc60b03SMartin MatuskaNote:  If you are generating lists of files using
896acc60b03SMartin Matuska.Xr find 1 ,
897acc60b03SMartin Matuskayou probably want to use
898acc60b03SMartin Matuska.Fl n
899acc60b03SMartin Matuskaas well.
900c5d360f8SMartin Matuska.It Fl Fl totals
90164287048SMartin Matuska(c, r, u modes only)
902c5d360f8SMartin MatuskaAfter archiving all files, print a summary to stderr.
903c5d360f8SMartin Matuska.It Fl U , Fl Fl unlink , Fl Fl unlink-first
904caf54c4fSMartin Matuska(x mode only)
905caf54c4fSMartin MatuskaUnlink files before creating them.
906c5d360f8SMartin MatuskaThis can be a minor performance optimization if most files
907c5d360f8SMartin Matuskaalready exist, but can make things slower if most files
908c5d360f8SMartin Matuskado not already exist.
909c5d360f8SMartin MatuskaThis flag also causes
910caf54c4fSMartin Matuska.Nm
911c5d360f8SMartin Matuskato remove intervening directory symlinks instead of
912c5d360f8SMartin Matuskareporting an error.
913c5d360f8SMartin MatuskaSee the SECURITY section below for more details.
914caf54c4fSMartin Matuska.It Fl Fl uid Ar id
915caf54c4fSMartin MatuskaUse the provided user id number and ignore the user
916caf54c4fSMartin Matuskaname from the archive.
917caf54c4fSMartin MatuskaOn create, if
918caf54c4fSMartin Matuska.Fl Fl uname
919caf54c4fSMartin Matuskais not also specified, the user name will be set to
920caf54c4fSMartin Matuskamatch the user id.
921caf54c4fSMartin Matuska.It Fl Fl uname Ar name
922caf54c4fSMartin MatuskaUse the provided user name.
923caf54c4fSMartin MatuskaOn extract, this overrides the user name in the archive;
924caf54c4fSMartin Matuskaif the provided user name does not exist on the system,
925caf54c4fSMartin Matuskait will be ignored and the user id
926caf54c4fSMartin Matuska(from the archive or from the
927caf54c4fSMartin Matuska.Fl Fl uid
928caf54c4fSMartin Matuskaoption)
929caf54c4fSMartin Matuskawill be used instead.
930caf54c4fSMartin MatuskaOn create, this sets the user name that will be stored
931caf54c4fSMartin Matuskain the archive;
932caf54c4fSMartin Matuskathe name is not verified against the system user database.
933caf54c4fSMartin Matuska.It Fl Fl use-compress-program Ar program
934caf54c4fSMartin MatuskaPipe the input (in x or t mode) or the output (in c mode) through
935caf54c4fSMartin Matuska.Pa program
936caf54c4fSMartin Matuskainstead of using the builtin compression support.
937b9128a37SMartin Matuska.It Fl Fl owner Ar name Ns Op : Ns Ar uid
938b9128a37SMartin MatuskaUse the provided user, if
939b9128a37SMartin Matuska.Ar uid
940b9128a37SMartin Matuskais not provided,
941b9128a37SMartin Matuska.Ar name
942b9128a37SMartin Matuskacan be either an username or numeric id.
943b9128a37SMartin MatuskaSee the
944b9128a37SMartin Matuska.Fl Fl uname
945b9128a37SMartin Matuskaoption for details.
946c5d360f8SMartin Matuska.It Fl v , Fl Fl verbose
947caf54c4fSMartin MatuskaProduce verbose output.
948caf54c4fSMartin MatuskaIn create and extract modes,
949caf54c4fSMartin Matuska.Nm
950caf54c4fSMartin Matuskawill list each file name as it is read from or written to
951caf54c4fSMartin Matuskathe archive.
952caf54c4fSMartin MatuskaIn list mode,
953caf54c4fSMartin Matuska.Nm
954caf54c4fSMartin Matuskawill produce output similar to that of
955caf54c4fSMartin Matuska.Xr ls 1 .
956cdf63a70SMartin MatuskaAn additional
957caf54c4fSMartin Matuska.Fl v
958cdf63a70SMartin Matuskaoption will also provide ls-like details in create and extract mode.
959c5d360f8SMartin Matuska.It Fl Fl version
960caf54c4fSMartin MatuskaPrint version of
961caf54c4fSMartin Matuska.Nm
962caf54c4fSMartin Matuskaand
963caf54c4fSMartin Matuska.Nm libarchive ,
964caf54c4fSMartin Matuskaand exit.
965c5d360f8SMartin Matuska.It Fl w , Fl Fl confirmation , Fl Fl interactive
966caf54c4fSMartin MatuskaAsk for confirmation for every action.
967c5d360f8SMartin Matuska.It Fl X Ar filename , Fl Fl exclude-from Ar filename
968caf54c4fSMartin MatuskaRead a list of exclusion patterns from the specified file.
969caf54c4fSMartin MatuskaSee
970c5d360f8SMartin Matuska.Fl Fl exclude
971caf54c4fSMartin Matuskafor more information about the handling of exclusions.
97264287048SMartin Matuska.It Fl Fl xattrs
97364287048SMartin Matuska(c, r, u, x modes only)
974f057565eSMartin MatuskaArchive or extract extended file attributes.
975f057565eSMartin MatuskaThis is the reverse of
97664287048SMartin Matuska.Fl Fl no-xattrs
97764287048SMartin Matuskaand the default behavior in c, r, and u modes or if
97864287048SMartin Matuska.Nm
97964287048SMartin Matuskais run in x mode as root.
980caf54c4fSMartin Matuska.It Fl y
981caf54c4fSMartin Matuska(c mode only)
982caf54c4fSMartin MatuskaCompress the resulting archive with
983caf54c4fSMartin Matuska.Xr bzip2 1 .
984caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored.
9855c831a5bSMartin MatuskaNote that this
986caf54c4fSMartin Matuska.Nm tar
9875c831a5bSMartin Matuskaimplementation recognizes bzip2 compression automatically when reading
9885c831a5bSMartin Matuskaarchives.
989c5d360f8SMartin Matuska.It Fl Z , Fl Fl compress , Fl Fl uncompress
990caf54c4fSMartin Matuska(c mode only)
991caf54c4fSMartin MatuskaCompress the resulting archive with
992caf54c4fSMartin Matuska.Xr compress 1 .
993caf54c4fSMartin MatuskaIn extract or list modes, this option is ignored.
9945c831a5bSMartin MatuskaNote that this
995caf54c4fSMartin Matuska.Nm tar
9965c831a5bSMartin Matuskaimplementation recognizes compress compression automatically when reading
9975c831a5bSMartin Matuskaarchives.
998c5d360f8SMartin Matuska.It Fl z , Fl Fl gunzip , Fl Fl gzip
999c5d360f8SMartin Matuska(c mode only)
1000c5d360f8SMartin MatuskaCompress the resulting archive with
1001c5d360f8SMartin Matuska.Xr gzip 1 .
1002c5d360f8SMartin MatuskaIn extract or list modes, this option is ignored.
10035c831a5bSMartin MatuskaNote that this
1004c5d360f8SMartin Matuska.Nm tar
10055c831a5bSMartin Matuskaimplementation recognizes gzip compression automatically when reading
10065c831a5bSMartin Matuskaarchives.
1007caf54c4fSMartin Matuska.El
1008caf54c4fSMartin Matuska.Sh ENVIRONMENT
1009caf54c4fSMartin MatuskaThe following environment variables affect the execution of
1010caf54c4fSMartin Matuska.Nm :
1011bd5e624aSMartin Matuska.Bl -tag -width indent
1012acc60b03SMartin Matuska.It Ev TAR_READER_OPTIONS
1013acc60b03SMartin MatuskaThe default options for format readers and compression readers.
1014acc60b03SMartin MatuskaThe
1015acc60b03SMartin Matuska.Fl Fl options
1016acc60b03SMartin Matuskaoption overrides this.
1017acc60b03SMartin Matuska.It Ev TAR_WRITER_OPTIONS
1018acc60b03SMartin MatuskaThe default options for format writers and compression writers.
1019acc60b03SMartin MatuskaThe
1020acc60b03SMartin Matuska.Fl Fl options
1021acc60b03SMartin Matuskaoption overrides this.
1022caf54c4fSMartin Matuska.It Ev LANG
1023caf54c4fSMartin MatuskaThe locale to use.
1024caf54c4fSMartin MatuskaSee
1025caf54c4fSMartin Matuska.Xr environ 7
1026caf54c4fSMartin Matuskafor more information.
1027caf54c4fSMartin Matuska.It Ev TAPE
1028c5d360f8SMartin MatuskaThe default device.
1029caf54c4fSMartin MatuskaThe
1030caf54c4fSMartin Matuska.Fl f
1031caf54c4fSMartin Matuskaoption overrides this.
1032c5d360f8SMartin MatuskaPlease see the description of the
1033c5d360f8SMartin Matuska.Fl f
1034c5d360f8SMartin Matuskaoption above for more details.
1035caf54c4fSMartin Matuska.It Ev TZ
1036caf54c4fSMartin MatuskaThe timezone to use when displaying dates.
1037caf54c4fSMartin MatuskaSee
1038caf54c4fSMartin Matuska.Xr environ 7
1039caf54c4fSMartin Matuskafor more information.
1040caf54c4fSMartin Matuska.El
1041c5d360f8SMartin Matuska.Sh EXIT STATUS
1042c5d360f8SMartin Matuska.Ex -std
1043caf54c4fSMartin Matuska.Sh EXAMPLES
1044caf54c4fSMartin MatuskaThe following creates a new archive
1045caf54c4fSMartin Matuskacalled
1046caf54c4fSMartin Matuska.Ar file.tar.gz
1047caf54c4fSMartin Matuskathat contains two files
1048caf54c4fSMartin Matuska.Ar source.c
1049caf54c4fSMartin Matuskaand
1050caf54c4fSMartin Matuska.Ar source.h :
1051caf54c4fSMartin Matuska.Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h
1052caf54c4fSMartin Matuska.Pp
1053caf54c4fSMartin MatuskaTo view a detailed table of contents for this
1054caf54c4fSMartin Matuskaarchive:
1055caf54c4fSMartin Matuska.Dl Nm Fl tvf Pa file.tar.gz
1056caf54c4fSMartin Matuska.Pp
1057caf54c4fSMartin MatuskaTo extract all entries from the archive on
1058caf54c4fSMartin Matuskathe default tape drive:
1059caf54c4fSMartin Matuska.Dl Nm Fl x
1060caf54c4fSMartin Matuska.Pp
1061caf54c4fSMartin MatuskaTo examine the contents of an ISO 9660 cdrom image:
1062caf54c4fSMartin Matuska.Dl Nm Fl tf Pa image.iso
1063caf54c4fSMartin Matuska.Pp
1064caf54c4fSMartin MatuskaTo move file hierarchies, invoke
1065caf54c4fSMartin Matuska.Nm
1066caf54c4fSMartin Matuskaas
1067f057565eSMartin Matuska.Dl Nm Fl cf Pa - Fl C Pa srcdir \&. | Nm Fl xpf Pa - Fl C Pa destdir
1068caf54c4fSMartin Matuskaor more traditionally
1069f057565eSMartin Matuska.Dl cd srcdir \&; Nm Fl cf Pa - \&. | ( cd destdir \&; Nm Fl xpf Pa - )
1070caf54c4fSMartin Matuska.Pp
1071caf54c4fSMartin MatuskaIn create mode, the list of files and directories to be archived
1072caf54c4fSMartin Matuskacan also include directory change instructions of the form
1073caf54c4fSMartin Matuska.Cm -C Ns Pa foo/baz
1074caf54c4fSMartin Matuskaand archive inclusions of the form
1075caf54c4fSMartin Matuska.Cm @ Ns Pa archive-file .
1076caf54c4fSMartin MatuskaFor example, the command line
1077caf54c4fSMartin Matuska.Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2
1078caf54c4fSMartin Matuskawill create a new archive
1079caf54c4fSMartin Matuska.Pa new.tar .
1080caf54c4fSMartin Matuska.Nm
1081caf54c4fSMartin Matuskawill read the file
1082caf54c4fSMartin Matuska.Pa foo1
1083caf54c4fSMartin Matuskafrom the current directory and add it to the output archive.
1084caf54c4fSMartin MatuskaIt will then read each entry from
1085caf54c4fSMartin Matuska.Pa old.tgz
1086caf54c4fSMartin Matuskaand add those entries to the output archive.
1087caf54c4fSMartin MatuskaFinally, it will switch to the
1088caf54c4fSMartin Matuska.Pa /tmp
1089caf54c4fSMartin Matuskadirectory and add
1090caf54c4fSMartin Matuska.Pa foo2
1091caf54c4fSMartin Matuskato the output archive.
1092caf54c4fSMartin Matuska.Pp
1093caf54c4fSMartin MatuskaAn input file in
1094caf54c4fSMartin Matuska.Xr mtree 5
1095caf54c4fSMartin Matuskaformat can be used to create an output archive with arbitrary ownership,
1096caf54c4fSMartin Matuskapermissions, or names that differ from existing data on disk:
1097cdf63a70SMartin Matuska.Bd -literal -offset indent
1098cdf63a70SMartin Matuska$ cat input.mtree
1099cdf63a70SMartin Matuska#mtree
1100cdf63a70SMartin Matuskausr/bin uid=0 gid=0 mode=0755 type=dir
1101cdf63a70SMartin Matuskausr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls
1102cdf63a70SMartin Matuska$ tar -cvf output.tar @input.mtree
1103cdf63a70SMartin Matuska.Ed
1104caf54c4fSMartin Matuska.Pp
1105caf54c4fSMartin MatuskaThe
1106c5d360f8SMartin Matuska.Fl Fl newer
1107caf54c4fSMartin Matuskaand
1108c5d360f8SMartin Matuska.Fl Fl newer-mtime
1109caf54c4fSMartin Matuskaswitches accept a variety of common date and time specifications, including
1110caf54c4fSMartin Matuska.Dq 12 Mar 2005 7:14:29pm ,
1111caf54c4fSMartin Matuska.Dq 2005-03-12 19:14 ,
1112caf54c4fSMartin Matuska.Dq 5 minutes ago ,
1113caf54c4fSMartin Matuskaand
1114caf54c4fSMartin Matuska.Dq 19:14 PST May 1 .
1115caf54c4fSMartin Matuska.Pp
1116caf54c4fSMartin MatuskaThe
1117c5d360f8SMartin Matuska.Fl Fl options
1118caf54c4fSMartin Matuskaargument can be used to control various details of archive generation
1119caf54c4fSMartin Matuskaor reading.
1120caf54c4fSMartin MatuskaFor example, you can generate mtree output which only contains
1121caf54c4fSMartin Matuska.Cm type , Cm time ,
1122caf54c4fSMartin Matuskaand
1123caf54c4fSMartin Matuska.Cm uid
1124caf54c4fSMartin Matuskakeywords:
1125c5d360f8SMartin Matuska.Dl Nm Fl cf Pa file.tar Fl Fl format=mtree Fl Fl options='!all,type,time,uid' Pa dir
1126caf54c4fSMartin Matuskaor you can set the compression level used by gzip or xz compression:
1127c5d360f8SMartin Matuska.Dl Nm Fl czf Pa file.tar Fl Fl options='compression-level=9' .
1128caf54c4fSMartin MatuskaFor more details, see the explanation of the
1129caf54c4fSMartin Matuska.Fn archive_read_set_options
1130caf54c4fSMartin Matuskaand
1131caf54c4fSMartin Matuska.Fn archive_write_set_options
1132caf54c4fSMartin MatuskaAPI calls that are described in
1133caf54c4fSMartin Matuska.Xr archive_read 3
1134caf54c4fSMartin Matuskaand
1135caf54c4fSMartin Matuska.Xr archive_write 3 .
1136caf54c4fSMartin Matuska.Sh COMPATIBILITY
1137caf54c4fSMartin MatuskaThe bundled-arguments format is supported for compatibility
1138caf54c4fSMartin Matuskawith historic implementations.
1139caf54c4fSMartin MatuskaIt consists of an initial word (with no leading - character) in which
1140caf54c4fSMartin Matuskaeach character indicates an option.
1141caf54c4fSMartin MatuskaArguments follow as separate words.
1142caf54c4fSMartin MatuskaThe order of the arguments must match the order
1143caf54c4fSMartin Matuskaof the corresponding characters in the bundled command word.
1144caf54c4fSMartin MatuskaFor example,
1145caf54c4fSMartin Matuska.Dl Nm Cm tbf 32 Pa file.tar
1146caf54c4fSMartin Matuskaspecifies three flags
1147caf54c4fSMartin Matuska.Cm t ,
1148caf54c4fSMartin Matuska.Cm b ,
1149caf54c4fSMartin Matuskaand
1150caf54c4fSMartin Matuska.Cm f .
1151caf54c4fSMartin MatuskaThe
1152caf54c4fSMartin Matuska.Cm b
1153caf54c4fSMartin Matuskaand
1154caf54c4fSMartin Matuska.Cm f
1155caf54c4fSMartin Matuskaflags both require arguments,
1156caf54c4fSMartin Matuskaso there must be two additional items
1157caf54c4fSMartin Matuskaon the command line.
1158caf54c4fSMartin MatuskaThe
1159caf54c4fSMartin Matuska.Ar 32
1160caf54c4fSMartin Matuskais the argument to the
1161caf54c4fSMartin Matuska.Cm b
1162caf54c4fSMartin Matuskaflag, and
1163caf54c4fSMartin Matuska.Ar file.tar
1164caf54c4fSMartin Matuskais the argument to the
1165caf54c4fSMartin Matuska.Cm f
1166caf54c4fSMartin Matuskaflag.
1167caf54c4fSMartin Matuska.Pp
1168caf54c4fSMartin MatuskaThe mode options c, r, t, u, and x and the options
1169caf54c4fSMartin Matuskab, f, l, m, o, v, and w comply with SUSv2.
1170caf54c4fSMartin Matuska.Pp
1171caf54c4fSMartin MatuskaFor maximum portability, scripts that invoke
1172caf54c4fSMartin Matuska.Nm tar
1173caf54c4fSMartin Matuskashould use the bundled-argument format above, should limit
1174caf54c4fSMartin Matuskathemselves to the
1175caf54c4fSMartin Matuska.Cm c ,
1176caf54c4fSMartin Matuska.Cm t ,
1177caf54c4fSMartin Matuskaand
1178caf54c4fSMartin Matuska.Cm x
1179caf54c4fSMartin Matuskamodes, and the
1180caf54c4fSMartin Matuska.Cm b ,
1181caf54c4fSMartin Matuska.Cm f ,
1182caf54c4fSMartin Matuska.Cm m ,
1183caf54c4fSMartin Matuska.Cm v ,
1184caf54c4fSMartin Matuskaand
1185caf54c4fSMartin Matuska.Cm w
1186caf54c4fSMartin Matuskaoptions.
1187caf54c4fSMartin Matuska.Pp
1188caf54c4fSMartin MatuskaAdditional long options are provided to improve compatibility with other
1189caf54c4fSMartin Matuskatar implementations.
1190caf54c4fSMartin Matuska.Sh SECURITY
1191caf54c4fSMartin MatuskaCertain security issues are common to many archiving programs, including
1192caf54c4fSMartin Matuska.Nm .
1193caf54c4fSMartin MatuskaIn particular, carefully-crafted archives can request that
1194caf54c4fSMartin Matuska.Nm
1195caf54c4fSMartin Matuskaextract files to locations outside of the target directory.
1196caf54c4fSMartin MatuskaThis can potentially be used to cause unwitting users to overwrite
1197caf54c4fSMartin Matuskafiles they did not intend to overwrite.
1198caf54c4fSMartin MatuskaIf the archive is being extracted by the superuser, any file
1199caf54c4fSMartin Matuskaon the system can potentially be overwritten.
1200caf54c4fSMartin MatuskaThere are three ways this can happen.
1201caf54c4fSMartin MatuskaAlthough
1202caf54c4fSMartin Matuska.Nm
1203caf54c4fSMartin Matuskahas mechanisms to protect against each one,
1204caf54c4fSMartin Matuskasavvy users should be aware of the implications:
1205caf54c4fSMartin Matuska.Bl -bullet -width indent
1206caf54c4fSMartin Matuska.It
1207caf54c4fSMartin MatuskaArchive entries can have absolute pathnames.
1208caf54c4fSMartin MatuskaBy default,
1209caf54c4fSMartin Matuska.Nm
1210caf54c4fSMartin Matuskaremoves the leading
1211caf54c4fSMartin Matuska.Pa /
1212caf54c4fSMartin Matuskacharacter from filenames before restoring them to guard against this problem.
1213caf54c4fSMartin Matuska.It
1214caf54c4fSMartin MatuskaArchive entries can have pathnames that include
1215caf54c4fSMartin Matuska.Pa ..
1216caf54c4fSMartin Matuskacomponents.
1217caf54c4fSMartin MatuskaBy default,
1218caf54c4fSMartin Matuska.Nm
1219caf54c4fSMartin Matuskawill not extract files containing
1220caf54c4fSMartin Matuska.Pa ..
1221caf54c4fSMartin Matuskacomponents in their pathname.
1222caf54c4fSMartin Matuska.It
1223caf54c4fSMartin MatuskaArchive entries can exploit symbolic links to restore
1224caf54c4fSMartin Matuskafiles to other directories.
1225caf54c4fSMartin MatuskaAn archive can restore a symbolic link to another directory,
1226caf54c4fSMartin Matuskathen use that link to restore a file into that directory.
1227caf54c4fSMartin MatuskaTo guard against this,
1228caf54c4fSMartin Matuska.Nm
1229caf54c4fSMartin Matuskachecks each extracted path for symlinks.
1230caf54c4fSMartin MatuskaIf the final path element is a symlink, it will be removed
1231caf54c4fSMartin Matuskaand replaced with the archive entry.
1232caf54c4fSMartin MatuskaIf
1233caf54c4fSMartin Matuska.Fl U
1234caf54c4fSMartin Matuskais specified, any intermediate symlink will also be unconditionally removed.
1235caf54c4fSMartin MatuskaIf neither
1236caf54c4fSMartin Matuska.Fl U
1237caf54c4fSMartin Matuskanor
1238caf54c4fSMartin Matuska.Fl P
1239caf54c4fSMartin Matuskais specified,
1240caf54c4fSMartin Matuska.Nm
1241caf54c4fSMartin Matuskawill refuse to extract the entry.
1242caf54c4fSMartin Matuska.El
1243caf54c4fSMartin MatuskaTo protect yourself, you should be wary of any archives that
1244caf54c4fSMartin Matuskacome from untrusted sources.
1245caf54c4fSMartin MatuskaYou should examine the contents of an archive with
1246caf54c4fSMartin Matuska.Dl Nm Fl tf Pa filename
1247caf54c4fSMartin Matuskabefore extraction.
1248caf54c4fSMartin MatuskaYou should use the
1249caf54c4fSMartin Matuska.Fl k
1250caf54c4fSMartin Matuskaoption to ensure that
1251caf54c4fSMartin Matuska.Nm
1252caf54c4fSMartin Matuskawill not overwrite any existing files or the
1253caf54c4fSMartin Matuska.Fl U
1254caf54c4fSMartin Matuskaoption to remove any pre-existing files.
1255caf54c4fSMartin MatuskaYou should generally not extract archives while running with super-user
1256caf54c4fSMartin Matuskaprivileges.
1257caf54c4fSMartin MatuskaNote that the
1258caf54c4fSMartin Matuska.Fl P
1259caf54c4fSMartin Matuskaoption to
1260caf54c4fSMartin Matuska.Nm
1261caf54c4fSMartin Matuskadisables the security checks above and allows you to extract
1262caf54c4fSMartin Matuskaan archive while preserving any absolute pathnames,
1263caf54c4fSMartin Matuska.Pa ..
1264caf54c4fSMartin Matuskacomponents, or symlinks to other directories.
1265caf54c4fSMartin Matuska.Sh SEE ALSO
1266caf54c4fSMartin Matuska.Xr bzip2 1 ,
1267caf54c4fSMartin Matuska.Xr compress 1 ,
1268caf54c4fSMartin Matuska.Xr cpio 1 ,
1269caf54c4fSMartin Matuska.Xr gzip 1 ,
1270caf54c4fSMartin Matuska.Xr mt 1 ,
1271caf54c4fSMartin Matuska.Xr pax 1 ,
1272caf54c4fSMartin Matuska.Xr shar 1 ,
1273c5d360f8SMartin Matuska.Xr xz 1 ,
1274caf54c4fSMartin Matuska.Xr libarchive 3 ,
1275caf54c4fSMartin Matuska.Xr libarchive-formats 5 ,
1276caf54c4fSMartin Matuska.Xr tar 5
1277caf54c4fSMartin Matuska.Sh STANDARDS
1278caf54c4fSMartin MatuskaThere is no current POSIX standard for the tar command; it appeared
1279caf54c4fSMartin Matuskain
1280caf54c4fSMartin Matuska.St -p1003.1-96
1281caf54c4fSMartin Matuskabut was dropped from
1282caf54c4fSMartin Matuska.St -p1003.1-2001 .
1283c5d360f8SMartin MatuskaThe options supported by this implementation were developed by surveying a
1284caf54c4fSMartin Matuskanumber of existing tar implementations as well as the old POSIX specification
1285caf54c4fSMartin Matuskafor tar and the current POSIX specification for pax.
1286caf54c4fSMartin Matuska.Pp
1287caf54c4fSMartin MatuskaThe ustar and pax interchange file formats are defined by
1288caf54c4fSMartin Matuska.St -p1003.1-2001
1289caf54c4fSMartin Matuskafor the pax command.
1290caf54c4fSMartin Matuska.Sh HISTORY
1291caf54c4fSMartin MatuskaA
1292caf54c4fSMartin Matuska.Nm tar
1293caf54c4fSMartin Matuskacommand appeared in Seventh Edition Unix, which was released in January, 1979.
1294caf54c4fSMartin MatuskaThere have been numerous other implementations,
1295caf54c4fSMartin Matuskamany of which extended the file format.
1296caf54c4fSMartin MatuskaJohn Gilmore's
1297caf54c4fSMartin Matuska.Nm pdtar
1298caf54c4fSMartin Matuskapublic-domain implementation (circa November, 1987)
1299caf54c4fSMartin Matuskawas quite influential, and formed the basis of GNU tar.
1300caf54c4fSMartin MatuskaGNU tar was included as the standard system tar
1301caf54c4fSMartin Matuskain
1302caf54c4fSMartin Matuska.Fx
1303caf54c4fSMartin Matuskabeginning with
1304caf54c4fSMartin Matuska.Fx 1.0 .
1305caf54c4fSMartin Matuska.Pp
1306caf54c4fSMartin MatuskaThis is a complete re-implementation based on the
1307caf54c4fSMartin Matuska.Xr libarchive 3
1308caf54c4fSMartin Matuskalibrary.
1309c5d360f8SMartin MatuskaIt was first released with
1310c5d360f8SMartin Matuska.Fx 5.4
1311c5d360f8SMartin Matuskain May, 2005.
1312caf54c4fSMartin Matuska.Sh BUGS
1313caf54c4fSMartin MatuskaThis program follows
1314caf54c4fSMartin Matuska.St -p1003.1-96
1315caf54c4fSMartin Matuskafor the definition of the
1316caf54c4fSMartin Matuska.Fl l
1317caf54c4fSMartin Matuskaoption.
1318caf54c4fSMartin MatuskaNote that GNU tar prior to version 1.15 treated
1319caf54c4fSMartin Matuska.Fl l
1320caf54c4fSMartin Matuskaas a synonym for the
1321c5d360f8SMartin Matuska.Fl Fl one-file-system
1322caf54c4fSMartin Matuskaoption.
1323caf54c4fSMartin Matuska.Pp
1324caf54c4fSMartin MatuskaThe
1325caf54c4fSMartin Matuska.Fl C Pa dir
1326caf54c4fSMartin Matuskaoption may differ from historic implementations.
1327caf54c4fSMartin Matuska.Pp
1328caf54c4fSMartin MatuskaAll archive output is written in correctly-sized blocks, even
1329caf54c4fSMartin Matuskaif the output is being compressed.
1330caf54c4fSMartin MatuskaWhether or not the last output block is padded to a full
1331caf54c4fSMartin Matuskablock size varies depending on the format and the
1332caf54c4fSMartin Matuskaoutput device.
1333caf54c4fSMartin MatuskaFor tar and cpio formats, the last block of output is padded
1334caf54c4fSMartin Matuskato a full block size if the output is being
1335caf54c4fSMartin Matuskawritten to standard output or to a character or block device such as
1336caf54c4fSMartin Matuskaa tape drive.
1337caf54c4fSMartin MatuskaIf the output is being written to a regular file, the last block
1338caf54c4fSMartin Matuskawill not be padded.
1339caf54c4fSMartin MatuskaMany compressors, including
1340caf54c4fSMartin Matuska.Xr gzip 1
1341caf54c4fSMartin Matuskaand
1342caf54c4fSMartin Matuska.Xr bzip2 1 ,
1343caf54c4fSMartin Matuskacomplain about the null padding when decompressing an archive created by
1344caf54c4fSMartin Matuska.Nm ,
1345caf54c4fSMartin Matuskaalthough they still extract it correctly.
1346caf54c4fSMartin Matuska.Pp
1347caf54c4fSMartin MatuskaThe compression and decompression is implemented internally, so
1348caf54c4fSMartin Matuskathere may be insignificant differences between the compressed output
1349caf54c4fSMartin Matuskagenerated by
1350caf54c4fSMartin Matuska.Dl Nm Fl czf Pa - file
1351caf54c4fSMartin Matuskaand that generated by
1352caf54c4fSMartin Matuska.Dl Nm Fl cf Pa - file | Nm gzip
1353caf54c4fSMartin Matuska.Pp
1354caf54c4fSMartin MatuskaThe default should be to read and write archives to the standard I/O paths,
1355caf54c4fSMartin Matuskabut tradition (and POSIX) dictates otherwise.
1356caf54c4fSMartin Matuska.Pp
1357caf54c4fSMartin MatuskaThe
1358caf54c4fSMartin Matuska.Cm r
1359caf54c4fSMartin Matuskaand
1360caf54c4fSMartin Matuska.Cm u
1361caf54c4fSMartin Matuskamodes require that the archive be uncompressed
1362caf54c4fSMartin Matuskaand located in a regular file on disk.
1363caf54c4fSMartin MatuskaOther archives can be modified using
1364caf54c4fSMartin Matuska.Cm c
1365caf54c4fSMartin Matuskamode with the
1366caf54c4fSMartin Matuska.Pa @archive-file
1367caf54c4fSMartin Matuskaextension.
1368caf54c4fSMartin Matuska.Pp
1369caf54c4fSMartin MatuskaTo archive a file called
1370caf54c4fSMartin Matuska.Pa @foo
1371caf54c4fSMartin Matuskaor
1372caf54c4fSMartin Matuska.Pa -foo
1373caf54c4fSMartin Matuskayou must specify it as
1374caf54c4fSMartin Matuska.Pa ./@foo
1375caf54c4fSMartin Matuskaor
1376caf54c4fSMartin Matuska.Pa ./-foo ,
1377caf54c4fSMartin Matuskarespectively.
1378caf54c4fSMartin Matuska.Pp
1379caf54c4fSMartin MatuskaIn create mode, a leading
1380caf54c4fSMartin Matuska.Pa ./
1381caf54c4fSMartin Matuskais always removed.
1382caf54c4fSMartin MatuskaA leading
1383caf54c4fSMartin Matuska.Pa /
1384caf54c4fSMartin Matuskais stripped unless the
1385caf54c4fSMartin Matuska.Fl P
1386caf54c4fSMartin Matuskaoption is specified.
1387caf54c4fSMartin Matuska.Pp
1388caf54c4fSMartin MatuskaThere needs to be better support for file selection on both create
1389caf54c4fSMartin Matuskaand extract.
1390caf54c4fSMartin Matuska.Pp
1391cdf63a70SMartin MatuskaThere is not yet any support for multi-volume archives.
1392caf54c4fSMartin Matuska.Pp
1393caf54c4fSMartin MatuskaConverting between dissimilar archive formats (such as tar and cpio) using the
1394caf54c4fSMartin Matuska.Cm @ Ns Pa -
1395caf54c4fSMartin Matuskaconvention can cause hard link information to be lost.
1396caf54c4fSMartin Matuska(This is a consequence of the incompatible ways that different archive
1397caf54c4fSMartin Matuskaformats store hardlink information.)
1398