xref: /dflybsd-src/contrib/libarchive/tar/bsdtar.1 (revision 9c82a63ede1d48aae2ac2b50446a015123e13f34)
160b4ad09SPeter Avalos.\" Copyright (c) 2003-2007 Tim Kientzle
260b4ad09SPeter Avalos.\" All rights reserved.
360b4ad09SPeter Avalos.\"
460b4ad09SPeter Avalos.\" Redistribution and use in source and binary forms, with or without
560b4ad09SPeter Avalos.\" modification, are permitted provided that the following conditions
660b4ad09SPeter Avalos.\" are met:
760b4ad09SPeter Avalos.\" 1. Redistributions of source code must retain the above copyright
860b4ad09SPeter Avalos.\"    notice, this list of conditions and the following disclaimer.
960b4ad09SPeter Avalos.\" 2. Redistributions in binary form must reproduce the above copyright
1060b4ad09SPeter Avalos.\"    notice, this list of conditions and the following disclaimer in the
1160b4ad09SPeter Avalos.\"    documentation and/or other materials provided with the distribution.
1260b4ad09SPeter Avalos.\"
1360b4ad09SPeter Avalos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1460b4ad09SPeter Avalos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1560b4ad09SPeter Avalos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1660b4ad09SPeter Avalos.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1760b4ad09SPeter Avalos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1860b4ad09SPeter Avalos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1960b4ad09SPeter Avalos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2060b4ad09SPeter Avalos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2160b4ad09SPeter Avalos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2260b4ad09SPeter Avalos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2360b4ad09SPeter Avalos.\" SUCH DAMAGE.
2460b4ad09SPeter Avalos.\"
258029ab02SPeter Avalos.\" $FreeBSD: src/usr.bin/tar/bsdtar.1,v 1.46 2008/12/06 07:37:55 kientzle Exp $
2660b4ad09SPeter Avalos.\"
27*9c82a63eSPeter Avalos.Dd Oct 12, 2009
2860b4ad09SPeter Avalos.Dt BSDTAR 1
2960b4ad09SPeter Avalos.Os
3060b4ad09SPeter Avalos.Sh NAME
3160b4ad09SPeter Avalos.Nm tar
3260b4ad09SPeter Avalos.Nd manipulate tape archives
3360b4ad09SPeter Avalos.Sh SYNOPSIS
3460b4ad09SPeter Avalos.Nm
3560b4ad09SPeter Avalos.Op Ar bundled-flags Ao args Ac
3660b4ad09SPeter Avalos.Op Ao Ar file Ac | Ao Ar pattern Ac ...
3760b4ad09SPeter Avalos.Nm
3860b4ad09SPeter Avalos.Brq Fl c
3960b4ad09SPeter Avalos.Op Ar options
408029ab02SPeter Avalos.Op Ar files | Ar directories
4160b4ad09SPeter Avalos.Nm
4260b4ad09SPeter Avalos.Brq Fl r | Fl u
4360b4ad09SPeter Avalos.Fl f Ar archive-file
4460b4ad09SPeter Avalos.Op Ar options
458029ab02SPeter Avalos.Op Ar files | Ar directories
4660b4ad09SPeter Avalos.Nm
4760b4ad09SPeter Avalos.Brq Fl t | Fl x
4860b4ad09SPeter Avalos.Op Ar options
4960b4ad09SPeter Avalos.Op Ar patterns
5060b4ad09SPeter Avalos.Sh DESCRIPTION
5160b4ad09SPeter Avalos.Nm
5260b4ad09SPeter Avaloscreates and manipulates streaming archive files.
5360b4ad09SPeter AvalosThis implementation can extract from tar, pax, cpio, zip, jar, ar,
5460b4ad09SPeter Avalosand ISO 9660 cdrom images and can create tar, pax, cpio, ar,
5560b4ad09SPeter Avalosand shar archives.
5660b4ad09SPeter Avalos.Pp
5760b4ad09SPeter AvalosThe first synopsis form shows a
5860b4ad09SPeter Avalos.Dq bundled
5960b4ad09SPeter Avalosoption word.
6060b4ad09SPeter AvalosThis usage is provided for compatibility with historical implementations.
6160b4ad09SPeter AvalosSee COMPATIBILITY below for details.
6260b4ad09SPeter Avalos.Pp
6360b4ad09SPeter AvalosThe other synopsis forms show the preferred usage.
6460b4ad09SPeter AvalosThe first option to
6560b4ad09SPeter Avalos.Nm
6660b4ad09SPeter Avalosis a mode indicator from the following list:
6760b4ad09SPeter Avalos.Bl -tag -compact -width indent
6860b4ad09SPeter Avalos.It Fl c
6960b4ad09SPeter AvalosCreate a new archive containing the specified items.
7060b4ad09SPeter Avalos.It Fl r
7160b4ad09SPeter AvalosLike
7260b4ad09SPeter Avalos.Fl c ,
7360b4ad09SPeter Avalosbut new entries are appended to the archive.
7460b4ad09SPeter AvalosNote that this only works on uncompressed archives stored in regular files.
7560b4ad09SPeter AvalosThe
7660b4ad09SPeter Avalos.Fl f
7760b4ad09SPeter Avalosoption is required.
7860b4ad09SPeter Avalos.It Fl t
7960b4ad09SPeter AvalosList archive contents to stdout.
8060b4ad09SPeter Avalos.It Fl u
8160b4ad09SPeter AvalosLike
8260b4ad09SPeter Avalos.Fl r ,
8360b4ad09SPeter Avalosbut new entries are added only if they have a modification date
8460b4ad09SPeter Avalosnewer than the corresponding entry in the archive.
8560b4ad09SPeter AvalosNote that this only works on uncompressed archives stored in regular files.
8660b4ad09SPeter AvalosThe
8760b4ad09SPeter Avalos.Fl f
8860b4ad09SPeter Avalosoption is required.
8960b4ad09SPeter Avalos.It Fl x
9060b4ad09SPeter AvalosExtract to disk from the archive.
9160b4ad09SPeter AvalosIf a file with the same name appears more than once in the archive,
9260b4ad09SPeter Avaloseach copy will be extracted, with later copies overwriting (replacing)
9360b4ad09SPeter Avalosearlier copies.
9460b4ad09SPeter Avalos.El
9560b4ad09SPeter Avalos.Pp
9660b4ad09SPeter AvalosIn
9760b4ad09SPeter Avalos.Fl c ,
9860b4ad09SPeter Avalos.Fl r ,
9960b4ad09SPeter Avalosor
10060b4ad09SPeter Avalos.Fl u
10160b4ad09SPeter Avalosmode, each specified file or directory is added to the
10260b4ad09SPeter Avalosarchive in the order specified on the command line.
10360b4ad09SPeter AvalosBy default, the contents of each directory are also archived.
10460b4ad09SPeter Avalos.Pp
10560b4ad09SPeter AvalosIn extract or list mode, the entire command line
10660b4ad09SPeter Avalosis read and parsed before the archive is opened.
10760b4ad09SPeter AvalosThe pathnames or patterns on the command line indicate
10860b4ad09SPeter Avaloswhich items in the archive should be processed.
10960b4ad09SPeter AvalosPatterns are shell-style globbing patterns as
11060b4ad09SPeter Avalosdocumented in
11160b4ad09SPeter Avalos.Xr tcsh 1 .
11260b4ad09SPeter Avalos.Sh OPTIONS
11360b4ad09SPeter AvalosUnless specifically stated otherwise, options are applicable in
11460b4ad09SPeter Avalosall operating modes.
11560b4ad09SPeter Avalos.Bl -tag -width indent
11660b4ad09SPeter Avalos.It Cm @ Ns Pa archive
11760b4ad09SPeter Avalos(c and r mode only)
11860b4ad09SPeter AvalosThe specified archive is opened and the entries
11960b4ad09SPeter Avalosin it will be appended to the current archive.
12060b4ad09SPeter AvalosAs a simple example,
12160b4ad09SPeter Avalos.Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar
12260b4ad09SPeter Avaloswrites a new archive to standard output containing a file
12360b4ad09SPeter Avalos.Pa newfile
12460b4ad09SPeter Avalosand all of the entries from
12560b4ad09SPeter Avalos.Pa original.tar .
12660b4ad09SPeter AvalosIn contrast,
12760b4ad09SPeter Avalos.Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar
12860b4ad09SPeter Avaloscreates a new archive with only two entries.
12960b4ad09SPeter AvalosSimilarly,
13060b4ad09SPeter Avalos.Dl Nm Fl czf Pa - Fl -format Cm pax Cm @ Ns Pa -
13160b4ad09SPeter Avalosreads an archive from standard input (whose format will be determined
13260b4ad09SPeter Avalosautomatically) and converts it into a gzip-compressed
13360b4ad09SPeter Avalospax-format archive on stdout.
13460b4ad09SPeter AvalosIn this way,
13560b4ad09SPeter Avalos.Nm
13660b4ad09SPeter Avaloscan be used to convert archives from one format to another.
13760b4ad09SPeter Avalos.It Fl b Ar blocksize
13860b4ad09SPeter AvalosSpecify the block size, in 512-byte records, for tape drive I/O.
13960b4ad09SPeter AvalosAs a rule, this argument is only needed when reading from or writing
14060b4ad09SPeter Avalosto tape drives, and usually not even then as the default block size of
14160b4ad09SPeter Avalos20 records (10240 bytes) is very common.
14260b4ad09SPeter Avalos.It Fl C Ar directory
14360b4ad09SPeter AvalosIn c and r mode, this changes the directory before adding
14460b4ad09SPeter Avalosthe following files.
14560b4ad09SPeter AvalosIn x mode, change directories after opening the archive
14660b4ad09SPeter Avalosbut before extracting entries from the archive.
1478029ab02SPeter Avalos.It Fl -check-links
14860b4ad09SPeter Avalos(c and r modes only)
14960b4ad09SPeter AvalosIssue a warning message unless all links to each file are archived.
1508029ab02SPeter Avalos.It Fl -chroot
15160b4ad09SPeter Avalos(x mode only)
15260b4ad09SPeter Avalos.Fn chroot
15360b4ad09SPeter Avalosto the current directory after processing any
15460b4ad09SPeter Avalos.Fl C
15560b4ad09SPeter Avalosoptions and before extracting any files.
1568029ab02SPeter Avalos.It Fl -exclude Ar pattern
15760b4ad09SPeter AvalosDo not process files or directories that match the
15860b4ad09SPeter Avalosspecified pattern.
15960b4ad09SPeter AvalosNote that exclusions take precedence over patterns or filenames
16060b4ad09SPeter Avalosspecified on the command line.
1618029ab02SPeter Avalos.It Fl -format Ar format
16260b4ad09SPeter Avalos(c, r, u mode only)
16360b4ad09SPeter AvalosUse the specified format for the created archive.
16460b4ad09SPeter AvalosSupported formats include
16560b4ad09SPeter Avalos.Dq cpio ,
16660b4ad09SPeter Avalos.Dq pax ,
16760b4ad09SPeter Avalos.Dq shar ,
16860b4ad09SPeter Avalosand
16960b4ad09SPeter Avalos.Dq ustar .
17060b4ad09SPeter AvalosOther formats may also be supported; see
17160b4ad09SPeter Avalos.Xr libarchive-formats 5
17260b4ad09SPeter Avalosfor more information about currently-supported formats.
17360b4ad09SPeter AvalosIn r and u modes, when extending an existing archive, the format specified
17460b4ad09SPeter Avaloshere must be compatible with the format of the existing archive on disk.
17560b4ad09SPeter Avalos.It Fl f Ar file
17660b4ad09SPeter AvalosRead the archive from or write the archive to the specified file.
17760b4ad09SPeter AvalosThe filename can be
17860b4ad09SPeter Avalos.Pa -
17960b4ad09SPeter Avalosfor standard input or standard output.
18060b4ad09SPeter AvalosIf not specified, the default tape device will be used.
18160b4ad09SPeter Avalos(On
18260b4ad09SPeter Avalos.Fx ,
18360b4ad09SPeter Avalosthe default tape device is
18460b4ad09SPeter Avalos.Pa /dev/sa0 . )
18560b4ad09SPeter Avalos.It Fl H
18660b4ad09SPeter Avalos(c and r mode only)
18760b4ad09SPeter AvalosSymbolic links named on the command line will be followed; the
18860b4ad09SPeter Avalostarget of the link will be archived, not the link itself.
18960b4ad09SPeter Avalos.It Fl h
19060b4ad09SPeter Avalos(c and r mode only)
19160b4ad09SPeter AvalosSynonym for
19260b4ad09SPeter Avalos.Fl L .
19360b4ad09SPeter Avalos.It Fl I
19460b4ad09SPeter AvalosSynonym for
19560b4ad09SPeter Avalos.Fl T .
1968029ab02SPeter Avalos.It Fl -include Ar pattern
19760b4ad09SPeter AvalosProcess only files or directories that match the specified pattern.
19860b4ad09SPeter AvalosNote that exclusions specified with
19960b4ad09SPeter Avalos.Fl -exclude
20060b4ad09SPeter Avalostake precedence over inclusions.
20160b4ad09SPeter AvalosIf no inclusions are explicitly specified, all entries are processed by
20260b4ad09SPeter Avalosdefault.
20360b4ad09SPeter AvalosThe
20460b4ad09SPeter Avalos.Fl -include
20560b4ad09SPeter Avalosoption is especially useful when filtering archives.
20660b4ad09SPeter AvalosFor example, the command
20760b4ad09SPeter Avalos.Dl Nm Fl c Fl f Pa new.tar Fl -include='*foo*' Cm @ Ns Pa old.tgz
20860b4ad09SPeter Avaloscreates a new archive
20960b4ad09SPeter Avalos.Pa new.tar
21060b4ad09SPeter Avaloscontaining only the entries from
21160b4ad09SPeter Avalos.Pa old.tgz
21260b4ad09SPeter Avaloscontaining the string
21360b4ad09SPeter Avalos.Sq foo .
21460b4ad09SPeter Avalos.It Fl j
21560b4ad09SPeter Avalos(c mode only)
21660b4ad09SPeter AvalosCompress the resulting archive with
21760b4ad09SPeter Avalos.Xr bzip2 1 .
21860b4ad09SPeter AvalosIn extract or list modes, this option is ignored.
21960b4ad09SPeter AvalosNote that, unlike other
22060b4ad09SPeter Avalos.Nm tar
22160b4ad09SPeter Avalosimplementations, this implementation recognizes bzip2 compression
22260b4ad09SPeter Avalosautomatically when reading archives.
22360b4ad09SPeter Avalos.It Fl k
22460b4ad09SPeter Avalos(x mode only)
22560b4ad09SPeter AvalosDo not overwrite existing files.
22660b4ad09SPeter AvalosIn particular, if a file appears more than once in an archive,
22760b4ad09SPeter Avaloslater copies will not overwrite earlier copies.
2288029ab02SPeter Avalos.It Fl -keep-newer-files
22960b4ad09SPeter Avalos(x mode only)
23060b4ad09SPeter AvalosDo not overwrite existing files that are newer than the
23160b4ad09SPeter Avalosversions appearing in the archive being extracted.
23260b4ad09SPeter Avalos.It Fl L
23360b4ad09SPeter Avalos(c and r mode only)
23460b4ad09SPeter AvalosAll symbolic links will be followed.
23560b4ad09SPeter AvalosNormally, symbolic links are archived as such.
23660b4ad09SPeter AvalosWith this option, the target of the link will be archived instead.
23760b4ad09SPeter Avalos.It Fl l
23860b4ad09SPeter AvalosThis is a synonym for the
23960b4ad09SPeter Avalos.Fl -check-links
24060b4ad09SPeter Avalosoption.
24160b4ad09SPeter Avalos.It Fl m
24260b4ad09SPeter Avalos(x mode only)
24360b4ad09SPeter AvalosDo not extract modification time.
24460b4ad09SPeter AvalosBy default, the modification time is set to the time stored in the archive.
24560b4ad09SPeter Avalos.It Fl n
24660b4ad09SPeter Avalos(c, r, u modes only)
24760b4ad09SPeter AvalosDo not recursively archive the contents of directories.
2488029ab02SPeter Avalos.It Fl -newer Ar date
24960b4ad09SPeter Avalos(c, r, u modes only)
25060b4ad09SPeter AvalosOnly include files and directories newer than the specified date.
25160b4ad09SPeter AvalosThis compares ctime entries.
2528029ab02SPeter Avalos.It Fl -newer-mtime Ar date
25360b4ad09SPeter Avalos(c, r, u modes only)
25460b4ad09SPeter AvalosLike
25560b4ad09SPeter Avalos.Fl -newer ,
25660b4ad09SPeter Avalosexcept it compares mtime entries instead of ctime entries.
2578029ab02SPeter Avalos.It Fl -newer-than Pa file
25860b4ad09SPeter Avalos(c, r, u modes only)
25960b4ad09SPeter AvalosOnly include files and directories newer than the specified file.
26060b4ad09SPeter AvalosThis compares ctime entries.
2618029ab02SPeter Avalos.It Fl -newer-mtime-than Pa file
26260b4ad09SPeter Avalos(c, r, u modes only)
26360b4ad09SPeter AvalosLike
26460b4ad09SPeter Avalos.Fl -newer-than ,
26560b4ad09SPeter Avalosexcept it compares mtime entries instead of ctime entries.
2668029ab02SPeter Avalos.It Fl -nodump
26760b4ad09SPeter Avalos(c and r modes only)
26860b4ad09SPeter AvalosHonor the nodump file flag by skipping this file.
2698029ab02SPeter Avalos.It Fl -null
27060b4ad09SPeter Avalos(use with
27160b4ad09SPeter Avalos.Fl I ,
27260b4ad09SPeter Avalos.Fl T ,
27360b4ad09SPeter Avalosor
27460b4ad09SPeter Avalos.Fl X )
27560b4ad09SPeter AvalosFilenames or patterns are separated by null characters,
27660b4ad09SPeter Avalosnot by newlines.
27760b4ad09SPeter AvalosThis is often used to read filenames output by the
27860b4ad09SPeter Avalos.Fl print0
27960b4ad09SPeter Avalosoption to
28060b4ad09SPeter Avalos.Xr find 1 .
28160b4ad09SPeter Avalos.It Fl -numeric-owner
28260b4ad09SPeter Avalos(x mode only)
28360b4ad09SPeter AvalosIgnore symbolic user and group names when restoring archives to disk,
28460b4ad09SPeter Avalosonly numeric uid and gid values will be obeyed.
28560b4ad09SPeter Avalos.It Fl O
28660b4ad09SPeter Avalos(x, t modes only)
28760b4ad09SPeter AvalosIn extract (-x) mode, files will be written to standard out rather than
28860b4ad09SPeter Avalosbeing extracted to disk.
28960b4ad09SPeter AvalosIn list (-t) mode, the file listing will be written to stderr rather than
29060b4ad09SPeter Avalosthe usual stdout.
29160b4ad09SPeter Avalos.It Fl o
29260b4ad09SPeter Avalos(x mode)
29360b4ad09SPeter AvalosUse the user and group of the user running the program rather
29460b4ad09SPeter Avalosthan those specified in the archive.
29560b4ad09SPeter AvalosNote that this has no significance unless
29660b4ad09SPeter Avalos.Fl p
29760b4ad09SPeter Avalosis specified, and the program is being run by the root user.
29860b4ad09SPeter AvalosIn this case, the file modes and flags from
29960b4ad09SPeter Avalosthe archive will be restored, but ACLs or owner information in
30060b4ad09SPeter Avalosthe archive will be discarded.
30160b4ad09SPeter Avalos.It Fl o
30260b4ad09SPeter Avalos(c, r, u mode)
30360b4ad09SPeter AvalosA synonym for
30460b4ad09SPeter Avalos.Fl -format Ar ustar
3058029ab02SPeter Avalos.It Fl -one-file-system
30660b4ad09SPeter Avalos(c, r, and u modes)
30760b4ad09SPeter AvalosDo not cross mount points.
3088029ab02SPeter Avalos.It Fl -options Ar options
3098029ab02SPeter AvalosSelect optional behaviors for particular modules.
3108029ab02SPeter AvalosThe argument is a text string containing comma-separated
3118029ab02SPeter Avaloskeywords and values.
3128029ab02SPeter AvalosThese are passed to the modules that handle particular
3138029ab02SPeter Avalosformats to control how those formats will behave.
3148029ab02SPeter AvalosEach option has one of the following forms:
3158029ab02SPeter Avalos.Bl -tag -compact -width indent
3168029ab02SPeter Avalos.It Ar key=value
3178029ab02SPeter AvalosThe key will be set to the specified value in every module that supports it.
3188029ab02SPeter AvalosModules that do not support this key will ignore it.
3198029ab02SPeter Avalos.It Ar key
3208029ab02SPeter AvalosThe key will be enabled in every module that supports it.
3218029ab02SPeter AvalosThis is equivalent to
3228029ab02SPeter Avalos.Ar key Ns Cm =1 .
3238029ab02SPeter Avalos.It Ar !key
3248029ab02SPeter AvalosThe key will be disabled in every module that supports it.
3258029ab02SPeter Avalos.It Ar module:key=value , Ar module:key , Ar module:!key
3268029ab02SPeter AvalosAs above, but the corresponding key and value will be provided
3278029ab02SPeter Avalosonly to modules whose name matches
3288029ab02SPeter Avalos.Ar module .
3298029ab02SPeter Avalos.El
3308029ab02SPeter AvalosThe currently supported modules and keys are:
3318029ab02SPeter Avalos.Bl -tag -compact -width indent
3328029ab02SPeter Avalos.It Cm iso9660:joliet
3338029ab02SPeter AvalosSupport Joliet extensions.
3348029ab02SPeter AvalosThis is enabled by default, use
3358029ab02SPeter Avalos.Cm !joliet
3368029ab02SPeter Avalosor
3378029ab02SPeter Avalos.Cm iso9660:!joliet
3388029ab02SPeter Avalosto disable.
339*9c82a63eSPeter Avalos.It Cm iso9660:rockridge
340*9c82a63eSPeter AvalosSupport Rock Ridge extensions.
341*9c82a63eSPeter AvalosThis is enabled by default, use
342*9c82a63eSPeter Avalos.Cm !rockridge
343*9c82a63eSPeter Avalosor
344*9c82a63eSPeter Avalos.Cm iso9660:!rockridge
345*9c82a63eSPeter Avalosto disable.
3468029ab02SPeter Avalos.It Cm gzip:compression-level
3478029ab02SPeter AvalosA decimal integer from 0 to 9 specifying the gzip compression level.
3488029ab02SPeter Avalos.It Cm xz:compression-level
3498029ab02SPeter AvalosA decimal integer from 0 to 9 specifying the xz compression level.
3508029ab02SPeter Avalos.It Cm mtree: Ns Ar keyword
3518029ab02SPeter AvalosThe mtree writer module allows you to specify which mtree keywords
3528029ab02SPeter Avaloswill be included in the output.
3538029ab02SPeter AvalosSupported keywords include:
3548029ab02SPeter Avalos.Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent ,
3558029ab02SPeter Avalos.Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 ,
3568029ab02SPeter Avalos.Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname .
3578029ab02SPeter AvalosThe default is equivalent to:
3588029ab02SPeter Avalos.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
3598029ab02SPeter Avalos.It Cm mtree:all
3608029ab02SPeter AvalosEnables all of the above keywords.
3618029ab02SPeter AvalosYou can also use
3628029ab02SPeter Avalos.Cm mtree:!all
3638029ab02SPeter Avalosto disable all keywords.
3648029ab02SPeter Avalos.It Cm mtree:use-set
3658029ab02SPeter AvalosEnable generation of
3668029ab02SPeter Avalos.Cm /set
3678029ab02SPeter Avaloslines in the output.
3688029ab02SPeter Avalos.It Cm mtree:indent
369*9c82a63eSPeter AvalosProduce human-readable output by indenting options and splitting lines
370*9c82a63eSPeter Avalosto fit into 80 columns.
371*9c82a63eSPeter Avalos.It Cm zip:compression Ns = Ns Ar type
372*9c82a63eSPeter AvalosUse
373*9c82a63eSPeter Avalos.Ar type
374*9c82a63eSPeter Avalosas compression method.
375*9c82a63eSPeter AvalosSupported values are store (uncompressed) and deflate (gzip algorithm).
3768029ab02SPeter Avalos.El
3778029ab02SPeter AvalosIf a provided option is not supported by any module, that
3788029ab02SPeter Avalosis a fatal error.
37960b4ad09SPeter Avalos.It Fl P
38060b4ad09SPeter AvalosPreserve pathnames.
38160b4ad09SPeter AvalosBy default, absolute pathnames (those that begin with a /
38260b4ad09SPeter Avaloscharacter) have the leading slash removed both when creating archives
38360b4ad09SPeter Avalosand extracting from them.
38460b4ad09SPeter AvalosAlso,
38560b4ad09SPeter Avalos.Nm
38660b4ad09SPeter Avaloswill refuse to extract archive entries whose pathnames contain
38760b4ad09SPeter Avalos.Pa ..
38860b4ad09SPeter Avalosor whose target directory would be altered by a symlink.
38960b4ad09SPeter AvalosThis option suppresses these behaviors.
39060b4ad09SPeter Avalos.It Fl p
39160b4ad09SPeter Avalos(x mode only)
39260b4ad09SPeter AvalosPreserve file permissions.
39360b4ad09SPeter AvalosAttempt to restore the full permissions, including owner, file modes, file
39460b4ad09SPeter Avalosflags and ACLs, if available, for each item extracted from the archive.
39560b4ad09SPeter AvalosBy default, newly-created files are owned by the user running
39660b4ad09SPeter Avalos.Nm ,
39760b4ad09SPeter Avalosthe file mode is restored for newly-created regular files, and
39860b4ad09SPeter Avalosall other types of entries receive default permissions.
39960b4ad09SPeter AvalosIf
40060b4ad09SPeter Avalos.Nm
40160b4ad09SPeter Avalosis being run by root, the default is to restore the owner unless the
40260b4ad09SPeter Avalos.Fl o
40360b4ad09SPeter Avalosoption is also specified.
40460b4ad09SPeter Avalos.It Fl q ( Fl -fast-read )
40560b4ad09SPeter Avalos(x and t mode only)
40660b4ad09SPeter AvalosExtract or list only the first archive entry that matches each pattern
40760b4ad09SPeter Avalosor filename operand.
40860b4ad09SPeter AvalosExit as soon as each specified pattern or filename has been matched.
40960b4ad09SPeter AvalosBy default, the archive is always read to the very end, since
41060b4ad09SPeter Avalosthere can be multiple entries with the same name and, by convention,
41160b4ad09SPeter Avaloslater entries overwrite earlier entries.
41260b4ad09SPeter AvalosThis option is provided as a performance optimization.
41360b4ad09SPeter Avalos.It Fl S
41460b4ad09SPeter Avalos(x mode only)
41560b4ad09SPeter AvalosExtract files as sparse files.
41660b4ad09SPeter AvalosFor every block on disk, check first if it contains only NULL bytes and seek
41760b4ad09SPeter Avalosover it otherwise.
41860b4ad09SPeter AvalosThis works similiar to the conv=sparse option of dd.
4198029ab02SPeter Avalos.It Fl -strip-components Ar count
4208029ab02SPeter Avalos(x mode only)
42160b4ad09SPeter AvalosRemove the specified number of leading path elements.
42260b4ad09SPeter AvalosPathnames with fewer elements will be silently skipped.
42360b4ad09SPeter AvalosNote that the pathname is edited after checking inclusion/exclusion patterns
42460b4ad09SPeter Avalosbut before security checks.
42560b4ad09SPeter Avalos.It Fl s Ar pattern
42660b4ad09SPeter AvalosModify file or archive member names according to
42760b4ad09SPeter Avalos.Pa pattern .
428*9c82a63eSPeter AvalosThe pattern has the format
429*9c82a63eSPeter Avalos.Ar /old/new/ Ns Op gps
430*9c82a63eSPeter Avaloswhere
431*9c82a63eSPeter Avalos.Ar old
432*9c82a63eSPeter Avalosis a basic regular expression,
433*9c82a63eSPeter Avalos.Ar new
434*9c82a63eSPeter Avalosis the replacement string of the matched part,
435*9c82a63eSPeter Avalosand the optional trailing letters modify
436*9c82a63eSPeter Avaloshow the replacement is handled.
437*9c82a63eSPeter AvalosIf
438*9c82a63eSPeter Avalos.Ar old
439*9c82a63eSPeter Avalosis not matched, the pattern is skipped.
440*9c82a63eSPeter AvalosWithin
441*9c82a63eSPeter Avalos.Ar new ,
442*9c82a63eSPeter Avalos~ is substituted with the match, \e1 to \e9 with the content of
44360b4ad09SPeter Avalosthe corresponding captured group.
44460b4ad09SPeter AvalosThe optional trailing g specifies that matching should continue
44560b4ad09SPeter Avalosafter the matched part and stopped on the first unmatched pattern.
44660b4ad09SPeter AvalosThe optional trailing s specifies that the pattern applies to the value
44760b4ad09SPeter Avalosof symbolic links.
44860b4ad09SPeter AvalosThe optional trailing p specifies that after a successful substitution
44960b4ad09SPeter Avalosthe original path name and the new path name should be printed to
45060b4ad09SPeter Avalosstandard error.
45160b4ad09SPeter Avalos.It Fl T Ar filename
45260b4ad09SPeter AvalosIn x or t mode,
45360b4ad09SPeter Avalos.Nm
45460b4ad09SPeter Avaloswill read the list of names to be extracted from
45560b4ad09SPeter Avalos.Pa filename .
45660b4ad09SPeter AvalosIn c mode,
45760b4ad09SPeter Avalos.Nm
45860b4ad09SPeter Avaloswill read names to be archived from
45960b4ad09SPeter Avalos.Pa filename .
46060b4ad09SPeter AvalosThe special name
46160b4ad09SPeter Avalos.Dq -C
46260b4ad09SPeter Avaloson a line by itself will cause the current directory to be changed to
46360b4ad09SPeter Avalosthe directory specified on the following line.
46460b4ad09SPeter AvalosNames are terminated by newlines unless
46560b4ad09SPeter Avalos.Fl -null
46660b4ad09SPeter Avalosis specified.
46760b4ad09SPeter AvalosNote that
46860b4ad09SPeter Avalos.Fl -null
46960b4ad09SPeter Avalosalso disables the special handling of lines containing
47060b4ad09SPeter Avalos.Dq -C .
47160b4ad09SPeter Avalos.It Fl U
47260b4ad09SPeter Avalos(x mode only)
47360b4ad09SPeter AvalosUnlink files before creating them.
47460b4ad09SPeter AvalosWithout this option,
47560b4ad09SPeter Avalos.Nm
47660b4ad09SPeter Avalosoverwrites existing files, which preserves existing hardlinks.
47760b4ad09SPeter AvalosWith this option, existing hardlinks will be broken, as will any
47860b4ad09SPeter Avalossymlink that would affect the location of an extracted file.
47960b4ad09SPeter Avalos.It Fl -use-compress-program Ar program
48060b4ad09SPeter AvalosPipe the input (in x or t mode) or the output (in c mode) through
48160b4ad09SPeter Avalos.Pa program
48260b4ad09SPeter Avalosinstead of using the builtin compression support.
48360b4ad09SPeter Avalos.It Fl v
48460b4ad09SPeter AvalosProduce verbose output.
48560b4ad09SPeter AvalosIn create and extract modes,
48660b4ad09SPeter Avalos.Nm
48760b4ad09SPeter Avaloswill list each file name as it is read from or written to
48860b4ad09SPeter Avalosthe archive.
48960b4ad09SPeter AvalosIn list mode,
49060b4ad09SPeter Avalos.Nm
49160b4ad09SPeter Avaloswill produce output similar to that of
49260b4ad09SPeter Avalos.Xr ls 1 .
49360b4ad09SPeter AvalosAdditional
49460b4ad09SPeter Avalos.Fl v
49560b4ad09SPeter Avalosoptions will provide additional detail.
4968029ab02SPeter Avalos.It Fl -version
4978029ab02SPeter AvalosPrint version of
4988029ab02SPeter Avalos.Nm
4998029ab02SPeter Avalosand
5008029ab02SPeter Avalos.Nm libarchive ,
5018029ab02SPeter Avalosand exit.
50260b4ad09SPeter Avalos.It Fl w
50360b4ad09SPeter AvalosAsk for confirmation for every action.
50460b4ad09SPeter Avalos.It Fl X Ar filename
50560b4ad09SPeter AvalosRead a list of exclusion patterns from the specified file.
50660b4ad09SPeter AvalosSee
50760b4ad09SPeter Avalos.Fl -exclude
50860b4ad09SPeter Avalosfor more information about the handling of exclusions.
50960b4ad09SPeter Avalos.It Fl y
51060b4ad09SPeter Avalos(c mode only)
51160b4ad09SPeter AvalosCompress the resulting archive with
51260b4ad09SPeter Avalos.Xr bzip2 1 .
51360b4ad09SPeter AvalosIn extract or list modes, this option is ignored.
51460b4ad09SPeter AvalosNote that, unlike other
51560b4ad09SPeter Avalos.Nm tar
51660b4ad09SPeter Avalosimplementations, this implementation recognizes bzip2 compression
51760b4ad09SPeter Avalosautomatically when reading archives.
51860b4ad09SPeter Avalos.It Fl z
51960b4ad09SPeter Avalos(c mode only)
52060b4ad09SPeter AvalosCompress the resulting archive with
52160b4ad09SPeter Avalos.Xr gzip 1 .
52260b4ad09SPeter AvalosIn extract or list modes, this option is ignored.
52360b4ad09SPeter AvalosNote that, unlike other
52460b4ad09SPeter Avalos.Nm tar
52560b4ad09SPeter Avalosimplementations, this implementation recognizes gzip compression
52660b4ad09SPeter Avalosautomatically when reading archives.
52760b4ad09SPeter Avalos.It Fl Z
52860b4ad09SPeter Avalos(c mode only)
52960b4ad09SPeter AvalosCompress the resulting archive with
53060b4ad09SPeter Avalos.Xr compress 1 .
53160b4ad09SPeter AvalosIn extract or list modes, this option is ignored.
53260b4ad09SPeter AvalosNote that, unlike other
53360b4ad09SPeter Avalos.Nm tar
53460b4ad09SPeter Avalosimplementations, this implementation recognizes compress compression
53560b4ad09SPeter Avalosautomatically when reading archives.
53660b4ad09SPeter Avalos.El
537*9c82a63eSPeter Avalos.Sh EXIT STATUS
538*9c82a63eSPeter Avalos.Ex -std
53960b4ad09SPeter Avalos.Sh ENVIRONMENT
54060b4ad09SPeter AvalosThe following environment variables affect the execution of
54160b4ad09SPeter Avalos.Nm :
54260b4ad09SPeter Avalos.Bl -tag -width ".Ev BLOCKSIZE"
54360b4ad09SPeter Avalos.It Ev LANG
54460b4ad09SPeter AvalosThe locale to use.
54560b4ad09SPeter AvalosSee
54660b4ad09SPeter Avalos.Xr environ 7
54760b4ad09SPeter Avalosfor more information.
54860b4ad09SPeter Avalos.It Ev TAPE
54960b4ad09SPeter AvalosThe default tape device.
55060b4ad09SPeter AvalosThe
55160b4ad09SPeter Avalos.Fl f
55260b4ad09SPeter Avalosoption overrides this.
55360b4ad09SPeter Avalos.It Ev TZ
55460b4ad09SPeter AvalosThe timezone to use when displaying dates.
55560b4ad09SPeter AvalosSee
55660b4ad09SPeter Avalos.Xr environ 7
55760b4ad09SPeter Avalosfor more information.
55860b4ad09SPeter Avalos.El
55960b4ad09SPeter Avalos.Sh FILES
56060b4ad09SPeter Avalos.Bl -tag -width ".Ev BLOCKSIZE"
56160b4ad09SPeter Avalos.It Pa /dev/sa0
56260b4ad09SPeter AvalosThe default tape device, if not overridden by the
56360b4ad09SPeter Avalos.Ev TAPE
56460b4ad09SPeter Avalosenvironment variable or the
56560b4ad09SPeter Avalos.Fl f
56660b4ad09SPeter Avalosoption.
56760b4ad09SPeter Avalos.El
56860b4ad09SPeter Avalos.Sh EXAMPLES
56960b4ad09SPeter AvalosThe following creates a new archive
57060b4ad09SPeter Avaloscalled
57160b4ad09SPeter Avalos.Ar file.tar.gz
57260b4ad09SPeter Avalosthat contains two files
57360b4ad09SPeter Avalos.Ar source.c
57460b4ad09SPeter Avalosand
57560b4ad09SPeter Avalos.Ar source.h :
57660b4ad09SPeter Avalos.Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h
57760b4ad09SPeter Avalos.Pp
57860b4ad09SPeter AvalosTo view a detailed table of contents for this
57960b4ad09SPeter Avalosarchive:
58060b4ad09SPeter Avalos.Dl Nm Fl tvf Pa file.tar.gz
58160b4ad09SPeter Avalos.Pp
58260b4ad09SPeter AvalosTo extract all entries from the archive on
58360b4ad09SPeter Avalosthe default tape drive:
58460b4ad09SPeter Avalos.Dl Nm Fl x
58560b4ad09SPeter Avalos.Pp
58660b4ad09SPeter AvalosTo examine the contents of an ISO 9660 cdrom image:
58760b4ad09SPeter Avalos.Dl Nm Fl tf Pa image.iso
58860b4ad09SPeter Avalos.Pp
58960b4ad09SPeter AvalosTo move file hierarchies, invoke
59060b4ad09SPeter Avalos.Nm
59160b4ad09SPeter Avalosas
59260b4ad09SPeter Avalos.Dl Nm Fl cf Pa - Fl C Pa srcdir\ . | Nm Fl xpf Pa - Fl C Pa destdir
59360b4ad09SPeter Avalosor more traditionally
59460b4ad09SPeter Avalos.Dl cd srcdir \&; Nm Fl cf Pa -\ . | ( cd destdir \&; Nm Fl xpf Pa - )
59560b4ad09SPeter Avalos.Pp
59660b4ad09SPeter AvalosIn create mode, the list of files and directories to be archived
59760b4ad09SPeter Avaloscan also include directory change instructions of the form
59860b4ad09SPeter Avalos.Cm -C Ns Pa foo/baz
59960b4ad09SPeter Avalosand archive inclusions of the form
60060b4ad09SPeter Avalos.Cm @ Ns Pa archive-file .
60160b4ad09SPeter AvalosFor example, the command line
60260b4ad09SPeter Avalos.Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2
60360b4ad09SPeter Avaloswill create a new archive
60460b4ad09SPeter Avalos.Pa new.tar .
60560b4ad09SPeter Avalos.Nm
60660b4ad09SPeter Avaloswill read the file
60760b4ad09SPeter Avalos.Pa foo1
60860b4ad09SPeter Avalosfrom the current directory and add it to the output archive.
60960b4ad09SPeter AvalosIt will then read each entry from
61060b4ad09SPeter Avalos.Pa old.tgz
61160b4ad09SPeter Avalosand add those entries to the output archive.
61260b4ad09SPeter AvalosFinally, it will switch to the
61360b4ad09SPeter Avalos.Pa /tmp
61460b4ad09SPeter Avalosdirectory and add
61560b4ad09SPeter Avalos.Pa foo2
61660b4ad09SPeter Avalosto the output archive.
61760b4ad09SPeter Avalos.Pp
61860b4ad09SPeter AvalosAn input file in
61960b4ad09SPeter Avalos.Xr mtree 5
62060b4ad09SPeter Avalosformat can be used to create an output archive with arbitrary ownership,
62160b4ad09SPeter Avalospermissions, or names that differ from existing data on disk:
62260b4ad09SPeter Avalos.Pp
62360b4ad09SPeter Avalos.Dl $ cat input.mtree
6248029ab02SPeter Avalos.Dl #mtree
62560b4ad09SPeter Avalos.Dl usr/bin uid=0 gid=0 mode=0755 type=dir
62660b4ad09SPeter Avalos.Dl usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls
62760b4ad09SPeter Avalos.Dl $ tar -cvf output.tar @input.mtree
62860b4ad09SPeter Avalos.Pp
62960b4ad09SPeter AvalosThe
63060b4ad09SPeter Avalos.Fl -newer
63160b4ad09SPeter Avalosand
63260b4ad09SPeter Avalos.Fl -newer-mtime
63360b4ad09SPeter Avalosswitches accept a variety of common date and time specifications, including
63460b4ad09SPeter Avalos.Dq 12 Mar 2005 7:14:29pm ,
63560b4ad09SPeter Avalos.Dq 2005-03-12 19:14 ,
63660b4ad09SPeter Avalos.Dq 5 minutes ago ,
63760b4ad09SPeter Avalosand
63860b4ad09SPeter Avalos.Dq 19:14 PST May 1 .
6398029ab02SPeter Avalos.Pp
6408029ab02SPeter AvalosThe
6418029ab02SPeter Avalos.Fl -options
6428029ab02SPeter Avalosargument can be used to control various details of archive generation
6438029ab02SPeter Avalosor reading.
6448029ab02SPeter AvalosFor example, you can generate mtree output which only contains
6458029ab02SPeter Avalos.Cm type , Cm time ,
6468029ab02SPeter Avalosand
6478029ab02SPeter Avalos.Cm uid
6488029ab02SPeter Avaloskeywords:
6498029ab02SPeter Avalos.Dl Nm Fl cf Pa file.tar Fl -format=mtree Fl -options='!all,type,time,uid' Pa dir
6508029ab02SPeter Avalosor you can set the compression level used by gzip or xz compression:
6518029ab02SPeter Avalos.Dl Nm Fl czf Pa file.tar Fl -options='compression-level=9' .
6528029ab02SPeter AvalosFor more details, see the explanation of the
6538029ab02SPeter Avalos.Fn archive_read_set_options
6548029ab02SPeter Avalosand
6558029ab02SPeter Avalos.Fn archive_write_set_options
6568029ab02SPeter AvalosAPI calls that are described in
6578029ab02SPeter Avalos.Xr archive_read 3
6588029ab02SPeter Avalosand
6598029ab02SPeter Avalos.Xr archive_write 3 .
66060b4ad09SPeter Avalos.Sh COMPATIBILITY
66160b4ad09SPeter AvalosThe bundled-arguments format is supported for compatibility
66260b4ad09SPeter Avaloswith historic implementations.
66360b4ad09SPeter AvalosIt consists of an initial word (with no leading - character) in which
66460b4ad09SPeter Avaloseach character indicates an option.
66560b4ad09SPeter AvalosArguments follow as separate words.
66660b4ad09SPeter AvalosThe order of the arguments must match the order
66760b4ad09SPeter Avalosof the corresponding characters in the bundled command word.
66860b4ad09SPeter AvalosFor example,
66960b4ad09SPeter Avalos.Dl Nm Cm tbf 32 Pa file.tar
67060b4ad09SPeter Avalosspecifies three flags
67160b4ad09SPeter Avalos.Cm t ,
67260b4ad09SPeter Avalos.Cm b ,
67360b4ad09SPeter Avalosand
67460b4ad09SPeter Avalos.Cm f .
67560b4ad09SPeter AvalosThe
67660b4ad09SPeter Avalos.Cm b
67760b4ad09SPeter Avalosand
67860b4ad09SPeter Avalos.Cm f
67960b4ad09SPeter Avalosflags both require arguments,
68060b4ad09SPeter Avalosso there must be two additional items
68160b4ad09SPeter Avaloson the command line.
68260b4ad09SPeter AvalosThe
68360b4ad09SPeter Avalos.Ar 32
68460b4ad09SPeter Avalosis the argument to the
68560b4ad09SPeter Avalos.Cm b
68660b4ad09SPeter Avalosflag, and
68760b4ad09SPeter Avalos.Ar file.tar
68860b4ad09SPeter Avalosis the argument to the
68960b4ad09SPeter Avalos.Cm f
69060b4ad09SPeter Avalosflag.
69160b4ad09SPeter Avalos.Pp
69260b4ad09SPeter AvalosThe mode options c, r, t, u, and x and the options
69360b4ad09SPeter Avalosb, f, l, m, o, v, and w comply with SUSv2.
69460b4ad09SPeter Avalos.Pp
69560b4ad09SPeter AvalosFor maximum portability, scripts that invoke
69660b4ad09SPeter Avalos.Nm tar
69760b4ad09SPeter Avalosshould use the bundled-argument format above, should limit
69860b4ad09SPeter Avalosthemselves to the
69960b4ad09SPeter Avalos.Cm c ,
70060b4ad09SPeter Avalos.Cm t ,
70160b4ad09SPeter Avalosand
70260b4ad09SPeter Avalos.Cm x
70360b4ad09SPeter Avalosmodes, and the
70460b4ad09SPeter Avalos.Cm b ,
70560b4ad09SPeter Avalos.Cm f ,
70660b4ad09SPeter Avalos.Cm m ,
70760b4ad09SPeter Avalos.Cm v ,
70860b4ad09SPeter Avalosand
70960b4ad09SPeter Avalos.Cm w
71060b4ad09SPeter Avalosoptions.
71160b4ad09SPeter Avalos.Pp
7128029ab02SPeter AvalosAdditional long options are provided to improve compatibility with other
7138029ab02SPeter Avalostar implementations.
71460b4ad09SPeter Avalos.Sh SECURITY
71560b4ad09SPeter AvalosCertain security issues are common to many archiving programs, including
71660b4ad09SPeter Avalos.Nm .
71760b4ad09SPeter AvalosIn particular, carefully-crafted archives can request that
71860b4ad09SPeter Avalos.Nm
71960b4ad09SPeter Avalosextract files to locations outside of the target directory.
72060b4ad09SPeter AvalosThis can potentially be used to cause unwitting users to overwrite
72160b4ad09SPeter Avalosfiles they did not intend to overwrite.
72260b4ad09SPeter AvalosIf the archive is being extracted by the superuser, any file
72360b4ad09SPeter Avaloson the system can potentially be overwritten.
72460b4ad09SPeter AvalosThere are three ways this can happen.
72560b4ad09SPeter AvalosAlthough
72660b4ad09SPeter Avalos.Nm
72760b4ad09SPeter Avaloshas mechanisms to protect against each one,
72860b4ad09SPeter Avalossavvy users should be aware of the implications:
72960b4ad09SPeter Avalos.Bl -bullet -width indent
73060b4ad09SPeter Avalos.It
73160b4ad09SPeter AvalosArchive entries can have absolute pathnames.
73260b4ad09SPeter AvalosBy default,
73360b4ad09SPeter Avalos.Nm
73460b4ad09SPeter Avalosremoves the leading
73560b4ad09SPeter Avalos.Pa /
73660b4ad09SPeter Avaloscharacter from filenames before restoring them to guard against this problem.
73760b4ad09SPeter Avalos.It
73860b4ad09SPeter AvalosArchive entries can have pathnames that include
73960b4ad09SPeter Avalos.Pa ..
74060b4ad09SPeter Avaloscomponents.
74160b4ad09SPeter AvalosBy default,
74260b4ad09SPeter Avalos.Nm
74360b4ad09SPeter Avaloswill not extract files containing
74460b4ad09SPeter Avalos.Pa ..
74560b4ad09SPeter Avaloscomponents in their pathname.
74660b4ad09SPeter Avalos.It
74760b4ad09SPeter AvalosArchive entries can exploit symbolic links to restore
74860b4ad09SPeter Avalosfiles to other directories.
74960b4ad09SPeter AvalosAn archive can restore a symbolic link to another directory,
75060b4ad09SPeter Avalosthen use that link to restore a file into that directory.
75160b4ad09SPeter AvalosTo guard against this,
75260b4ad09SPeter Avalos.Nm
75360b4ad09SPeter Avaloschecks each extracted path for symlinks.
75460b4ad09SPeter AvalosIf the final path element is a symlink, it will be removed
75560b4ad09SPeter Avalosand replaced with the archive entry.
75660b4ad09SPeter AvalosIf
75760b4ad09SPeter Avalos.Fl U
75860b4ad09SPeter Avalosis specified, any intermediate symlink will also be unconditionally removed.
75960b4ad09SPeter AvalosIf neither
76060b4ad09SPeter Avalos.Fl U
76160b4ad09SPeter Avalosnor
76260b4ad09SPeter Avalos.Fl P
76360b4ad09SPeter Avalosis specified,
76460b4ad09SPeter Avalos.Nm
76560b4ad09SPeter Avaloswill refuse to extract the entry.
76660b4ad09SPeter Avalos.El
76760b4ad09SPeter AvalosTo protect yourself, you should be wary of any archives that
76860b4ad09SPeter Avaloscome from untrusted sources.
76960b4ad09SPeter AvalosYou should examine the contents of an archive with
77060b4ad09SPeter Avalos.Dl Nm Fl tf Pa filename
77160b4ad09SPeter Avalosbefore extraction.
77260b4ad09SPeter AvalosYou should use the
77360b4ad09SPeter Avalos.Fl k
77460b4ad09SPeter Avalosoption to ensure that
77560b4ad09SPeter Avalos.Nm
77660b4ad09SPeter Avaloswill not overwrite any existing files or the
77760b4ad09SPeter Avalos.Fl U
77860b4ad09SPeter Avalosoption to remove any pre-existing files.
77960b4ad09SPeter AvalosYou should generally not extract archives while running with super-user
78060b4ad09SPeter Avalosprivileges.
78160b4ad09SPeter AvalosNote that the
78260b4ad09SPeter Avalos.Fl P
78360b4ad09SPeter Avalosoption to
78460b4ad09SPeter Avalos.Nm
78560b4ad09SPeter Avalosdisables the security checks above and allows you to extract
78660b4ad09SPeter Avalosan archive while preserving any absolute pathnames,
78760b4ad09SPeter Avalos.Pa ..
78860b4ad09SPeter Avaloscomponents, or symlinks to other directories.
78960b4ad09SPeter Avalos.Sh SEE ALSO
79060b4ad09SPeter Avalos.Xr bzip2 1 ,
79160b4ad09SPeter Avalos.Xr compress 1 ,
79260b4ad09SPeter Avalos.Xr cpio 1 ,
79360b4ad09SPeter Avalos.Xr gzip 1 ,
79460b4ad09SPeter Avalos.Xr mt 1 ,
79560b4ad09SPeter Avalos.Xr pax 1 ,
79660b4ad09SPeter Avalos.Xr shar 1 ,
79760b4ad09SPeter Avalos.Xr libarchive 3 ,
79860b4ad09SPeter Avalos.Xr libarchive-formats 5 ,
79960b4ad09SPeter Avalos.Xr tar 5
80060b4ad09SPeter Avalos.Sh STANDARDS
80160b4ad09SPeter AvalosThere is no current POSIX standard for the tar command; it appeared
80260b4ad09SPeter Avalosin
80360b4ad09SPeter Avalos.St -p1003.1-96
80460b4ad09SPeter Avalosbut was dropped from
80560b4ad09SPeter Avalos.St -p1003.1-2001 .
80660b4ad09SPeter AvalosThe options used by this implementation were developed by surveying a
80760b4ad09SPeter Avalosnumber of existing tar implementations as well as the old POSIX specification
80860b4ad09SPeter Avalosfor tar and the current POSIX specification for pax.
80960b4ad09SPeter Avalos.Pp
81060b4ad09SPeter AvalosThe ustar and pax interchange file formats are defined by
81160b4ad09SPeter Avalos.St -p1003.1-2001
81260b4ad09SPeter Avalosfor the pax command.
81360b4ad09SPeter Avalos.Sh HISTORY
81460b4ad09SPeter AvalosA
81560b4ad09SPeter Avalos.Nm tar
81660b4ad09SPeter Avaloscommand appeared in Seventh Edition Unix, which was released in January, 1979.
81760b4ad09SPeter AvalosThere have been numerous other implementations,
81860b4ad09SPeter Avalosmany of which extended the file format.
81960b4ad09SPeter AvalosJohn Gilmore's
82060b4ad09SPeter Avalos.Nm pdtar
82160b4ad09SPeter Avalospublic-domain implementation (circa November, 1987)
82260b4ad09SPeter Avaloswas quite influential, and formed the basis of GNU tar.
82360b4ad09SPeter AvalosGNU tar was included as the standard system tar
82460b4ad09SPeter Avalosin
82560b4ad09SPeter Avalos.Fx
82660b4ad09SPeter Avalosbeginning with
82760b4ad09SPeter Avalos.Fx 1.0 .
82860b4ad09SPeter Avalos.Pp
82960b4ad09SPeter AvalosThis is a complete re-implementation based on the
83060b4ad09SPeter Avalos.Xr libarchive 3
83160b4ad09SPeter Avaloslibrary.
83260b4ad09SPeter Avalos.Sh BUGS
83360b4ad09SPeter AvalosThis program follows
83460b4ad09SPeter Avalos.St -p1003.1-96
83560b4ad09SPeter Avalosfor the definition of the
83660b4ad09SPeter Avalos.Fl l
83760b4ad09SPeter Avalosoption.
83860b4ad09SPeter AvalosNote that GNU tar prior to version 1.15 treated
83960b4ad09SPeter Avalos.Fl l
84060b4ad09SPeter Avalosas a synonym for the
84160b4ad09SPeter Avalos.Fl -one-file-system
84260b4ad09SPeter Avalosoption.
84360b4ad09SPeter Avalos.Pp
84460b4ad09SPeter AvalosThe
84560b4ad09SPeter Avalos.Fl C Pa dir
84660b4ad09SPeter Avalosoption may differ from historic implementations.
84760b4ad09SPeter Avalos.Pp
84860b4ad09SPeter AvalosAll archive output is written in correctly-sized blocks, even
84960b4ad09SPeter Avalosif the output is being compressed.
85060b4ad09SPeter AvalosWhether or not the last output block is padded to a full
85160b4ad09SPeter Avalosblock size varies depending on the format and the
85260b4ad09SPeter Avalosoutput device.
85360b4ad09SPeter AvalosFor tar and cpio formats, the last block of output is padded
85460b4ad09SPeter Avalosto a full block size if the output is being
85560b4ad09SPeter Avaloswritten to standard output or to a character or block device such as
85660b4ad09SPeter Avalosa tape drive.
85760b4ad09SPeter AvalosIf the output is being written to a regular file, the last block
85860b4ad09SPeter Avaloswill not be padded.
85960b4ad09SPeter AvalosMany compressors, including
86060b4ad09SPeter Avalos.Xr gzip 1
86160b4ad09SPeter Avalosand
86260b4ad09SPeter Avalos.Xr bzip2 1 ,
86360b4ad09SPeter Avaloscomplain about the null padding when decompressing an archive created by
86460b4ad09SPeter Avalos.Nm ,
86560b4ad09SPeter Avalosalthough they still extract it correctly.
86660b4ad09SPeter Avalos.Pp
86760b4ad09SPeter AvalosThe compression and decompression is implemented internally, so
86860b4ad09SPeter Avalosthere may be insignificant differences between the compressed output
86960b4ad09SPeter Avalosgenerated by
87060b4ad09SPeter Avalos.Dl Nm Fl czf Pa - file
87160b4ad09SPeter Avalosand that generated by
87260b4ad09SPeter Avalos.Dl Nm Fl cf Pa - file | Nm gzip
87360b4ad09SPeter Avalos.Pp
87460b4ad09SPeter AvalosThe default should be to read and write archives to the standard I/O paths,
87560b4ad09SPeter Avalosbut tradition (and POSIX) dictates otherwise.
87660b4ad09SPeter Avalos.Pp
87760b4ad09SPeter AvalosThe
87860b4ad09SPeter Avalos.Cm r
87960b4ad09SPeter Avalosand
88060b4ad09SPeter Avalos.Cm u
88160b4ad09SPeter Avalosmodes require that the archive be uncompressed
88260b4ad09SPeter Avalosand located in a regular file on disk.
88360b4ad09SPeter AvalosOther archives can be modified using
88460b4ad09SPeter Avalos.Cm c
88560b4ad09SPeter Avalosmode with the
88660b4ad09SPeter Avalos.Pa @archive-file
88760b4ad09SPeter Avalosextension.
88860b4ad09SPeter Avalos.Pp
88960b4ad09SPeter AvalosTo archive a file called
89060b4ad09SPeter Avalos.Pa @foo
89160b4ad09SPeter Avalosor
89260b4ad09SPeter Avalos.Pa -foo
89360b4ad09SPeter Avalosyou must specify it as
89460b4ad09SPeter Avalos.Pa ./@foo
89560b4ad09SPeter Avalosor
89660b4ad09SPeter Avalos.Pa ./-foo ,
89760b4ad09SPeter Avalosrespectively.
89860b4ad09SPeter Avalos.Pp
89960b4ad09SPeter AvalosIn create mode, a leading
90060b4ad09SPeter Avalos.Pa ./
90160b4ad09SPeter Avalosis always removed.
90260b4ad09SPeter AvalosA leading
90360b4ad09SPeter Avalos.Pa /
90460b4ad09SPeter Avalosis stripped unless the
90560b4ad09SPeter Avalos.Fl P
90660b4ad09SPeter Avalosoption is specified.
90760b4ad09SPeter Avalos.Pp
90860b4ad09SPeter AvalosThere needs to be better support for file selection on both create
90960b4ad09SPeter Avalosand extract.
91060b4ad09SPeter Avalos.Pp
91160b4ad09SPeter AvalosThere is not yet any support for multi-volume archives or for archiving
91260b4ad09SPeter Avalossparse files.
91360b4ad09SPeter Avalos.Pp
91460b4ad09SPeter AvalosConverting between dissimilar archive formats (such as tar and cpio) using the
91560b4ad09SPeter Avalos.Cm @ Ns Pa -
91660b4ad09SPeter Avalosconvention can cause hard link information to be lost.
91760b4ad09SPeter Avalos(This is a consequence of the incompatible ways that different archive
91860b4ad09SPeter Avalosformats store hardlink information.)
91960b4ad09SPeter Avalos.Pp
92060b4ad09SPeter AvalosThere are alternative long options for many of the short options that
92160b4ad09SPeter Avalosare deliberately not documented.
922