Blame tar/bsdtar.1

Packit 08bd4c
.\" Copyright (c) 2003-2007 Tim Kientzle
Packit 08bd4c
.\" Copyright (c) 2017 Martin Matuska
Packit 08bd4c
.\" All rights reserved.
Packit 08bd4c
.\"
Packit 08bd4c
.\" Redistribution and use in source and binary forms, with or without
Packit 08bd4c
.\" modification, are permitted provided that the following conditions
Packit 08bd4c
.\" are met:
Packit 08bd4c
.\" 1. Redistributions of source code must retain the above copyright
Packit 08bd4c
.\"    notice, this list of conditions and the following disclaimer.
Packit 08bd4c
.\" 2. Redistributions in binary form must reproduce the above copyright
Packit 08bd4c
.\"    notice, this list of conditions and the following disclaimer in the
Packit 08bd4c
.\"    documentation and/or other materials provided with the distribution.
Packit 08bd4c
.\"
Packit 08bd4c
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
Packit 08bd4c
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 08bd4c
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit 08bd4c
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
Packit 08bd4c
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 08bd4c
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit 08bd4c
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit 08bd4c
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit 08bd4c
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit 08bd4c
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit 08bd4c
.\" SUCH DAMAGE.
Packit 08bd4c
.\"
Packit 08bd4c
.\" $FreeBSD$
Packit 08bd4c
.\"
Packit 08bd4c
.Dd February 25, 2017
Packit 08bd4c
.Dt TAR 1
Packit 08bd4c
.Os
Packit 08bd4c
.Sh NAME
Packit 08bd4c
.Nm tar
Packit 08bd4c
.Nd manipulate tape archives
Packit 08bd4c
.Sh SYNOPSIS
Packit 08bd4c
.Nm
Packit 08bd4c
.Op Ar bundled-flags Ao args Ac
Packit 08bd4c
.Op Ao Ar file Ac | Ao Ar pattern Ac ...
Packit 08bd4c
.Nm
Packit 08bd4c
.Brq Fl c
Packit 08bd4c
.Op Ar options
Packit 08bd4c
.Op Ar files | Ar directories
Packit 08bd4c
.Nm
Packit 08bd4c
.Brq Fl r | Fl u
Packit 08bd4c
.Fl f Ar archive-file
Packit 08bd4c
.Op Ar options
Packit 08bd4c
.Op Ar files | Ar directories
Packit 08bd4c
.Nm
Packit 08bd4c
.Brq Fl t | Fl x
Packit 08bd4c
.Op Ar options
Packit 08bd4c
.Op Ar patterns
Packit 08bd4c
.Sh DESCRIPTION
Packit 08bd4c
.Nm
Packit 08bd4c
creates and manipulates streaming archive files.
Packit 08bd4c
This implementation can extract from tar, pax, cpio, zip, jar, ar, xar,
Packit 08bd4c
rpm, 7-zip, and ISO 9660 cdrom images and can create tar, pax, cpio, ar, zip,
Packit 08bd4c
7-zip, and shar archives.
Packit 08bd4c
.Pp
Packit 08bd4c
The first synopsis form shows a
Packit 08bd4c
.Dq bundled
Packit 08bd4c
option word.
Packit 08bd4c
This usage is provided for compatibility with historical implementations.
Packit 08bd4c
See COMPATIBILITY below for details.
Packit 08bd4c
.Pp
Packit 08bd4c
The other synopsis forms show the preferred usage.
Packit 08bd4c
The first option to
Packit 08bd4c
.Nm
Packit 08bd4c
is a mode indicator from the following list:
Packit 08bd4c
.Bl -tag -compact -width indent
Packit 08bd4c
.It Fl c
Packit 08bd4c
Create a new archive containing the specified items.
Packit 08bd4c
The long option form is
Packit 08bd4c
.Fl Fl create .
Packit 08bd4c
.It Fl r
Packit 08bd4c
Like
Packit 08bd4c
.Fl c ,
Packit 08bd4c
but new entries are appended to the archive.
Packit 08bd4c
Note that this only works on uncompressed archives stored in regular files.
Packit 08bd4c
The
Packit 08bd4c
.Fl f
Packit 08bd4c
option is required.
Packit 08bd4c
The long option form is
Packit 08bd4c
.Fl Fl append .
Packit 08bd4c
.It Fl t
Packit 08bd4c
List archive contents to stdout.
Packit 08bd4c
The long option form is
Packit 08bd4c
.Fl Fl list .
Packit 08bd4c
.It Fl u
Packit 08bd4c
Like
Packit 08bd4c
.Fl r ,
Packit 08bd4c
but new entries are added only if they have a modification date
Packit 08bd4c
newer than the corresponding entry in the archive.
Packit 08bd4c
Note that this only works on uncompressed archives stored in regular files.
Packit 08bd4c
The
Packit 08bd4c
.Fl f
Packit 08bd4c
option is required.
Packit 08bd4c
The long form is
Packit 08bd4c
.Fl Fl update .
Packit 08bd4c
.It Fl x
Packit 08bd4c
Extract to disk from the archive.
Packit 08bd4c
If a file with the same name appears more than once in the archive,
Packit 08bd4c
each copy will be extracted, with later copies overwriting (replacing)
Packit 08bd4c
earlier copies.
Packit 08bd4c
The long option form is
Packit 08bd4c
.Fl Fl extract .
Packit 08bd4c
.El
Packit 08bd4c
.Pp
Packit 08bd4c
In
Packit 08bd4c
.Fl c ,
Packit 08bd4c
.Fl r ,
Packit 08bd4c
or
Packit 08bd4c
.Fl u
Packit 08bd4c
mode, each specified file or directory is added to the
Packit 08bd4c
archive in the order specified on the command line.
Packit 08bd4c
By default, the contents of each directory are also archived.
Packit 08bd4c
.Pp
Packit 08bd4c
In extract or list mode, the entire command line
Packit 08bd4c
is read and parsed before the archive is opened.
Packit 08bd4c
The pathnames or patterns on the command line indicate
Packit 08bd4c
which items in the archive should be processed.
Packit 08bd4c
Patterns are shell-style globbing patterns as
Packit 08bd4c
documented in
Packit 08bd4c
.Xr tcsh 1 .
Packit 08bd4c
.Sh OPTIONS
Packit 08bd4c
Unless specifically stated otherwise, options are applicable in
Packit 08bd4c
all operating modes.
Packit 08bd4c
.Bl -tag -width indent
Packit 08bd4c
.It Cm @ Ns Pa archive
Packit 08bd4c
(c and r modes only)
Packit 08bd4c
The specified archive is opened and the entries
Packit 08bd4c
in it will be appended to the current archive.
Packit 08bd4c
As a simple example,
Packit 08bd4c
.Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar
Packit 08bd4c
writes a new archive to standard output containing a file
Packit 08bd4c
.Pa newfile
Packit 08bd4c
and all of the entries from
Packit 08bd4c
.Pa original.tar .
Packit 08bd4c
In contrast,
Packit 08bd4c
.Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar
Packit 08bd4c
creates a new archive with only two entries.
Packit 08bd4c
Similarly,
Packit 08bd4c
.Dl Nm Fl czf Pa - Fl Fl format Cm pax Cm @ Ns Pa -
Packit 08bd4c
reads an archive from standard input (whose format will be determined
Packit 08bd4c
automatically) and converts it into a gzip-compressed
Packit 08bd4c
pax-format archive on stdout.
Packit 08bd4c
In this way,
Packit 08bd4c
.Nm
Packit 08bd4c
can be used to convert archives from one format to another.
Packit 08bd4c
.It Fl a , Fl Fl auto-compress
Packit 08bd4c
(c mode only)
Packit 08bd4c
Use the archive suffix to decide a set of the format and
Packit 08bd4c
the compressions.
Packit 08bd4c
As a simple example,
Packit 08bd4c
.Dl Nm Fl a Fl cf Pa archive.tgz source.c source.h
Packit 08bd4c
creates a new archive with restricted pax format and gzip compression,
Packit 08bd4c
.Dl Nm Fl a Fl cf Pa archive.tar.bz2.uu source.c source.h
Packit 08bd4c
creates a new archive with restricted pax format and bzip2 compression
Packit 08bd4c
and uuencode compression,
Packit 08bd4c
.Dl Nm Fl a Fl cf Pa archive.zip source.c source.h
Packit 08bd4c
creates a new archive with zip format,
Packit 08bd4c
.Dl Nm Fl a Fl jcf Pa archive.tgz source.c source.h
Packit 08bd4c
ignores the
Packit 08bd4c
.Dq -j
Packit 08bd4c
option, and creates a new archive with restricted pax format
Packit 08bd4c
and gzip compression,
Packit 08bd4c
.Dl Nm Fl a Fl jcf Pa archive.xxx source.c source.h
Packit 08bd4c
if it is unknown suffix or no suffix, creates a new archive with
Packit 08bd4c
restricted pax format and bzip2 compression.
Packit 08bd4c
.It Fl Fl acls
Packit 08bd4c
(c, r, u, x modes only)
Packit 08bd4c
Archive or extract POSIX.1e or NFSv4 ACLs. This is the reverse of
Packit 08bd4c
.Fl Fl no-acls
Packit 08bd4c
and the default behavior in c, r, and u modes (except on Mac OS X) or if
Packit 08bd4c
.Nm
Packit 08bd4c
is run in x mode as root. On Mac OS X this option translates extended ACLs
Packit 08bd4c
to NFSv4 ACLs. To store extended ACLs the
Packit 08bd4c
.Fl Fl mac-metadata
Packit 08bd4c
option is preferred.
Packit 08bd4c
.It Fl B , Fl Fl read-full-blocks
Packit 08bd4c
Ignored for compatibility with other
Packit 08bd4c
.Xr tar 1
Packit 08bd4c
implementations.
Packit 08bd4c
.It Fl b Ar blocksize , Fl Fl block-size Ar blocksize
Packit 08bd4c
Specify the block size, in 512-byte records, for tape drive I/O.
Packit 08bd4c
As a rule, this argument is only needed when reading from or writing
Packit 08bd4c
to tape drives, and usually not even then as the default block size of
Packit 08bd4c
20 records (10240 bytes) is very common.
Packit 08bd4c
.It Fl C Ar directory , Fl Fl cd Ar directory , Fl Fl directory Ar directory
Packit 08bd4c
In c and r mode, this changes the directory before adding
Packit 08bd4c
the following files.
Packit 08bd4c
In x mode, change directories after opening the archive
Packit 08bd4c
but before extracting entries from the archive.
Packit 08bd4c
.It Fl Fl chroot
Packit 08bd4c
(x mode only)
Packit 08bd4c
.Fn chroot
Packit 08bd4c
to the current directory after processing any
Packit 08bd4c
.Fl C
Packit 08bd4c
options and before extracting any files.
Packit 08bd4c
.It Fl Fl clear-nochange-fflags
Packit 08bd4c
(x mode only)
Packit 08bd4c
Before removing file system objects to replace them, clear platform-specific
Packit 08bd4c
file flags that might prevent removal.
Packit 08bd4c
.It Fl Fl exclude Ar pattern
Packit 08bd4c
Do not process files or directories that match the
Packit 08bd4c
specified pattern.
Packit 08bd4c
Note that exclusions take precedence over patterns or filenames
Packit 08bd4c
specified on the command line.
Packit 08bd4c
.It Fl Fl fflags
Packit 08bd4c
(c, r, u, x modes only)
Packit 08bd4c
Archive or extract file flags. This is the reverse of
Packit 08bd4c
.Fl Fl no-fflags
Packit 08bd4c
and the default behavior in c, r, and u modes or if
Packit 08bd4c
.Nm
Packit 08bd4c
is run in x mode as root.
Packit 08bd4c
.It Fl Fl format Ar format
Packit 08bd4c
(c, r, u mode only)
Packit 08bd4c
Use the specified format for the created archive.
Packit 08bd4c
Supported formats include
Packit 08bd4c
.Dq cpio ,
Packit 08bd4c
.Dq pax ,
Packit 08bd4c
.Dq shar ,
Packit 08bd4c
and
Packit 08bd4c
.Dq ustar .
Packit 08bd4c
Other formats may also be supported; see
Packit 08bd4c
.Xr libarchive-formats 5
Packit 08bd4c
for more information about currently-supported formats.
Packit 08bd4c
In r and u modes, when extending an existing archive, the format specified
Packit 08bd4c
here must be compatible with the format of the existing archive on disk.
Packit 08bd4c
.It Fl f Ar file , Fl Fl file Ar file
Packit 08bd4c
Read the archive from or write the archive to the specified file.
Packit 08bd4c
The filename can be
Packit 08bd4c
.Pa -
Packit 08bd4c
for standard input or standard output.
Packit 08bd4c
The default varies by system;
Packit 08bd4c
on
Packit 08bd4c
.Fx ,
Packit 08bd4c
the default is
Packit 08bd4c
.Pa /dev/sa0 ;
Packit 08bd4c
on Linux, the default is
Packit 08bd4c
.Pa /dev/st0 .
Packit 08bd4c
.It Fl Fl gid Ar id
Packit 08bd4c
Use the provided group id number.
Packit 08bd4c
On extract, this overrides the group id in the archive;
Packit 08bd4c
the group name in the archive will be ignored.
Packit 08bd4c
On create, this overrides the group id read from disk;
Packit 08bd4c
if
Packit 08bd4c
.Fl Fl gname
Packit 08bd4c
is not also specified, the group name will be set to
Packit 08bd4c
match the group id.
Packit 08bd4c
.It Fl Fl gname Ar name
Packit 08bd4c
Use the provided group name.
Packit 08bd4c
On extract, this overrides the group name in the archive;
Packit 08bd4c
if the provided group name does not exist on the system,
Packit 08bd4c
the group id
Packit 08bd4c
(from the archive or from the
Packit 08bd4c
.Fl Fl gid
Packit 08bd4c
option)
Packit 08bd4c
will be used instead.
Packit 08bd4c
On create, this sets the group name that will be stored
Packit 08bd4c
in the archive;
Packit 08bd4c
the name will not be verified against the system group database.
Packit 08bd4c
.It Fl H
Packit 08bd4c
(c and r modes only)
Packit 08bd4c
Symbolic links named on the command line will be followed; the
Packit 08bd4c
target of the link will be archived, not the link itself.
Packit 08bd4c
.It Fl h
Packit 08bd4c
(c and r modes only)
Packit 08bd4c
Synonym for
Packit 08bd4c
.Fl L .
Packit 08bd4c
.It Fl I
Packit 08bd4c
Synonym for
Packit 08bd4c
.Fl T .
Packit 08bd4c
.It Fl Fl help
Packit 08bd4c
Show usage.
Packit 08bd4c
.It Fl Fl hfsCompression
Packit 08bd4c
(x mode only)
Packit 08bd4c
Mac OS X specific (v10.6 or later). Compress extracted regular files with HFS+
Packit 08bd4c
compression.
Packit 08bd4c
.It Fl Fl ignore-zeros
Packit 08bd4c
An alias of
Packit 08bd4c
.Fl Fl options Cm read_concatenated_archives
Packit 08bd4c
for compatibility with GNU tar.
Packit 08bd4c
.It Fl Fl include Ar pattern
Packit 08bd4c
Process only files or directories that match the specified pattern.
Packit 08bd4c
Note that exclusions specified with
Packit 08bd4c
.Fl Fl exclude
Packit 08bd4c
take precedence over inclusions.
Packit 08bd4c
If no inclusions are explicitly specified, all entries are processed by
Packit 08bd4c
default.
Packit 08bd4c
The
Packit 08bd4c
.Fl Fl include
Packit 08bd4c
option is especially useful when filtering archives.
Packit 08bd4c
For example, the command
Packit 08bd4c
.Dl Nm Fl c Fl f Pa new.tar Fl Fl include='*foo*' Cm @ Ns Pa old.tgz
Packit 08bd4c
creates a new archive
Packit 08bd4c
.Pa new.tar
Packit 08bd4c
containing only the entries from
Packit 08bd4c
.Pa old.tgz
Packit 08bd4c
containing the string
Packit 08bd4c
.Sq foo .
Packit 08bd4c
.It Fl J , Fl Fl xz
Packit 08bd4c
(c mode only)
Packit 08bd4c
Compress the resulting archive with
Packit 08bd4c
.Xr xz 1 .
Packit 08bd4c
In extract or list modes, this option is ignored.
Packit 08bd4c
Note that, unlike other
Packit 08bd4c
.Nm tar
Packit 08bd4c
implementations, this implementation recognizes XZ compression
Packit 08bd4c
automatically when reading archives.
Packit 08bd4c
.It Fl j , Fl Fl bzip , Fl Fl bzip2 , Fl Fl bunzip2
Packit 08bd4c
(c mode only)
Packit 08bd4c
Compress the resulting archive with
Packit 08bd4c
.Xr bzip2 1 .
Packit 08bd4c
In extract or list modes, this option is ignored.
Packit 08bd4c
Note that, unlike other
Packit 08bd4c
.Nm tar
Packit 08bd4c
implementations, this implementation recognizes bzip2 compression
Packit 08bd4c
automatically when reading archives.
Packit 08bd4c
.It Fl k , Fl Fl keep-old-files
Packit 08bd4c
(x mode only)
Packit 08bd4c
Do not overwrite existing files.
Packit 08bd4c
In particular, if a file appears more than once in an archive,
Packit 08bd4c
later copies will not overwrite earlier copies.
Packit 08bd4c
.It Fl Fl keep-newer-files
Packit 08bd4c
(x mode only)
Packit 08bd4c
Do not overwrite existing files that are newer than the
Packit 08bd4c
versions appearing in the archive being extracted.
Packit 08bd4c
.It Fl L , Fl Fl dereference
Packit 08bd4c
(c and r modes only)
Packit 08bd4c
All symbolic links will be followed.
Packit 08bd4c
Normally, symbolic links are archived as such.
Packit 08bd4c
With this option, the target of the link will be archived instead.
Packit 08bd4c
.It Fl l , Fl Fl check-links
Packit 08bd4c
(c and r modes only)
Packit 08bd4c
Issue a warning message unless all links to each file are archived.
Packit 08bd4c
.It Fl Fl lrzip
Packit 08bd4c
(c mode only)
Packit 08bd4c
Compress the resulting archive with
Packit 08bd4c
.Xr lrzip 1 .
Packit 08bd4c
In extract or list modes, this option is ignored.
Packit 08bd4c
.It Fl Fl lz4
Packit 08bd4c
(c mode only)
Packit 08bd4c
Compress the archive with lz4-compatible compression before writing it.
Packit 08bd4c
In input mode, this option is ignored; lz4 compression is recognized
Packit 08bd4c
automatically on input.
Packit 08bd4c
.It Fl Fl lzma
Packit 08bd4c
(c mode only) Compress the resulting archive with the original LZMA algorithm.
Packit 08bd4c
Use of this option is discouraged and new archives should be created with
Packit 08bd4c
.Fl Fl xz
Packit 08bd4c
instead.
Packit 08bd4c
Note that, unlike other
Packit 08bd4c
.Nm tar
Packit 08bd4c
implementations, this implementation recognizes LZMA compression
Packit 08bd4c
automatically when reading archives.
Packit 08bd4c
.It Fl Fl lzop
Packit 08bd4c
(c mode only)
Packit 08bd4c
Compress the resulting archive with
Packit 08bd4c
.Xr lzop 1 .
Packit 08bd4c
In extract or list modes, this option is ignored.
Packit 08bd4c
.It Fl m , Fl Fl modification-time
Packit 08bd4c
(x mode only)
Packit 08bd4c
Do not extract modification time.
Packit 08bd4c
By default, the modification time is set to the time stored in the archive.
Packit 08bd4c
.It Fl Fl mac-metadata
Packit 08bd4c
(c, r, u and x mode only)
Packit 08bd4c
Mac OS X specific. Archive or extract extended ACLs and extended attributes
Packit 08bd4c
using
Packit 08bd4c
.Xr copyfile 3
Packit 08bd4c
in AppleDouble format. This is the reverse of
Packit 08bd4c
.Fl Fl no-mac-metadata .
Packit 08bd4c
and the default behavior in c, r, and u modes or if
Packit 08bd4c
.Nm
Packit 08bd4c
is run in x mode as root.
Packit 08bd4c
.It Fl n , Fl Fl norecurse , Fl Fl no-recursion
Packit 08bd4c
(c, r, u modes only)
Packit 08bd4c
Do not recursively archive the contents of directories.
Packit 08bd4c
.It Fl Fl newer Ar date
Packit 08bd4c
(c, r, u modes only)
Packit 08bd4c
Only include files and directories newer than the specified date.
Packit 08bd4c
This compares ctime entries.
Packit 08bd4c
.It Fl Fl newer-mtime Ar date
Packit 08bd4c
(c, r, u modes only)
Packit 08bd4c
Like
Packit 08bd4c
.Fl Fl newer ,
Packit 08bd4c
except it compares mtime entries instead of ctime entries.
Packit 08bd4c
.It Fl Fl newer-than Pa file
Packit 08bd4c
(c, r, u modes only)
Packit 08bd4c
Only include files and directories newer than the specified file.
Packit 08bd4c
This compares ctime entries.
Packit 08bd4c
.It Fl Fl newer-mtime-than Pa file
Packit 08bd4c
(c, r, u modes only)
Packit 08bd4c
Like
Packit 08bd4c
.Fl Fl newer-than ,
Packit 08bd4c
except it compares mtime entries instead of ctime entries.
Packit 08bd4c
.It Fl Fl nodump
Packit 08bd4c
(c and r modes only)
Packit 08bd4c
Honor the nodump file flag by skipping this file.
Packit 08bd4c
.It Fl Fl nopreserveHFSCompression
Packit 08bd4c
(x mode only)
Packit 08bd4c
Mac OS X specific (v10.6 or later). Do not compress extracted regular files
Packit 08bd4c
which were compressed with HFS+ compression before archived.
Packit 08bd4c
By default, compress the regular files again with HFS+ compression.
Packit 08bd4c
.It Fl Fl null
Packit 08bd4c
(use with
Packit 08bd4c
.Fl I
Packit 08bd4c
or
Packit 08bd4c
.Fl T )
Packit 08bd4c
Filenames or patterns are separated by null characters,
Packit 08bd4c
not by newlines.
Packit 08bd4c
This is often used to read filenames output by the
Packit 08bd4c
.Fl print0
Packit 08bd4c
option to
Packit 08bd4c
.Xr find 1 .
Packit 08bd4c
.It Fl Fl no-acls
Packit 08bd4c
(c, r, u, x modes only)
Packit 08bd4c
Do not archive or extract POSIX.1e or NFSv4 ACLs. This is the reverse of
Packit 08bd4c
.Fl Fl acls
Packit 08bd4c
and the default behavior if
Packit 08bd4c
.Nm
Packit 08bd4c
is run as non-root in x mode (on Mac OS X as any user in c, r, u and x modes).
Packit 08bd4c
.It Fl Fl no-fflags
Packit 08bd4c
(c, r, u, x modes only)
Packit 08bd4c
Do not archive or extract file flags. This is the reverse of
Packit 08bd4c
.Fl Fl fflags
Packit 08bd4c
and the default behavior if
Packit 08bd4c
.Nm
Packit 08bd4c
is run as non-root in x mode.
Packit 08bd4c
.It Fl Fl no-mac-metadata
Packit 08bd4c
(x mode only)
Packit 08bd4c
Mac OS X specific. Do not archive or extract ACLs and extended attributes using
Packit 08bd4c
.Xr copyfile 3
Packit 08bd4c
in AppleDouble format. This is the reverse of
Packit 08bd4c
.Fl Fl mac-metadata .
Packit 08bd4c
and the default behavior if
Packit 08bd4c
.Nm
Packit 08bd4c
is run as non-root in x mode.
Packit 08bd4c
.It Fl n , Fl Fl norecurse , Fl Fl no-recursion
Packit 08bd4c
.It Fl Fl no-same-owner
Packit 08bd4c
(x mode only)
Packit 08bd4c
Do not extract owner and group IDs.
Packit 08bd4c
This is the reverse of
Packit 08bd4c
.Fl Fl same-owner
Packit 08bd4c
and the default behavior if
Packit 08bd4c
.Nm
Packit 08bd4c
is run as non-root.
Packit 08bd4c
.It Fl Fl no-same-permissions
Packit 08bd4c
(x mode only)
Packit 08bd4c
Do not extract full permissions (SGID, SUID, sticky bit, ACLs,
Packit 08bd4c
extended attributes or extended file flags).
Packit 08bd4c
This is the reverse of
Packit 08bd4c
.Fl p
Packit 08bd4c
and the default behavior if
Packit 08bd4c
.Nm
Packit 08bd4c
is run as non-root.
Packit 08bd4c
.It Fl Fl no-xattrs
Packit 08bd4c
(c, r, u, x modes only)
Packit 08bd4c
Do not archive or extract extended attributes. This is the reverse of
Packit 08bd4c
.Fl Fl xattrs
Packit 08bd4c
and the default behavior if
Packit 08bd4c
.Nm
Packit 08bd4c
is run as non-root in x mode.
Packit 08bd4c
.It Fl Fl numeric-owner
Packit 08bd4c
This is equivalent to
Packit 08bd4c
.Fl Fl uname
Packit 08bd4c
.Qq
Packit 08bd4c
.Fl Fl gname
Packit 08bd4c
.Qq .
Packit 08bd4c
On extract, it causes user and group names in the archive
Packit 08bd4c
to be ignored in favor of the numeric user and group ids.
Packit 08bd4c
On create, it causes user and group names to not be stored
Packit 08bd4c
in the archive.
Packit 08bd4c
.It Fl O , Fl Fl to-stdout
Packit 08bd4c
(x, t modes only)
Packit 08bd4c
In extract (-x) mode, files will be written to standard out rather than
Packit 08bd4c
being extracted to disk.
Packit 08bd4c
In list (-t) mode, the file listing will be written to stderr rather than
Packit 08bd4c
the usual stdout.
Packit 08bd4c
.It Fl o
Packit 08bd4c
(x mode)
Packit 08bd4c
Use the user and group of the user running the program rather
Packit 08bd4c
than those specified in the archive.
Packit 08bd4c
Note that this has no significance unless
Packit 08bd4c
.Fl p
Packit 08bd4c
is specified, and the program is being run by the root user.
Packit 08bd4c
In this case, the file modes and flags from
Packit 08bd4c
the archive will be restored, but ACLs or owner information in
Packit 08bd4c
the archive will be discarded.
Packit 08bd4c
.It Fl o
Packit 08bd4c
(c, r, u mode)
Packit 08bd4c
A synonym for
Packit 08bd4c
.Fl Fl format Ar ustar
Packit 08bd4c
.It Fl Fl older Ar date
Packit 08bd4c
(c, r, u modes only)
Packit 08bd4c
Only include files and directories older than the specified date.
Packit 08bd4c
This compares ctime entries.
Packit 08bd4c
.It Fl Fl older-mtime Ar date
Packit 08bd4c
(c, r, u modes only)
Packit 08bd4c
Like
Packit 08bd4c
.Fl Fl older ,
Packit 08bd4c
except it compares mtime entries instead of ctime entries.
Packit 08bd4c
.It Fl Fl older-than Pa file
Packit 08bd4c
(c, r, u modes only)
Packit 08bd4c
Only include files and directories older than the specified file.
Packit 08bd4c
This compares ctime entries.
Packit 08bd4c
.It Fl Fl older-mtime-than Pa file
Packit 08bd4c
(c, r, u modes only)
Packit 08bd4c
Like
Packit 08bd4c
.Fl Fl older-than ,
Packit 08bd4c
except it compares mtime entries instead of ctime entries.
Packit 08bd4c
.It Fl Fl one-file-system
Packit 08bd4c
(c, r, and u modes)
Packit 08bd4c
Do not cross mount points.
Packit 08bd4c
.It Fl Fl options Ar options
Packit 08bd4c
Select optional behaviors for particular modules.
Packit 08bd4c
The argument is a text string containing comma-separated
Packit 08bd4c
keywords and values.
Packit 08bd4c
These are passed to the modules that handle particular
Packit 08bd4c
formats to control how those formats will behave.
Packit 08bd4c
Each option has one of the following forms:
Packit 08bd4c
.Bl -tag -compact -width indent
Packit 08bd4c
.It Ar key=value
Packit 08bd4c
The key will be set to the specified value in every module that supports it.
Packit 08bd4c
Modules that do not support this key will ignore it.
Packit 08bd4c
.It Ar key
Packit 08bd4c
The key will be enabled in every module that supports it.
Packit 08bd4c
This is equivalent to
Packit 08bd4c
.Ar key Ns Cm =1 .
Packit 08bd4c
.It Ar !key
Packit 08bd4c
The key will be disabled in every module that supports it.
Packit 08bd4c
.It Ar module:key=value , Ar module:key , Ar module:!key
Packit 08bd4c
As above, but the corresponding key and value will be provided
Packit 08bd4c
only to modules whose name matches
Packit 08bd4c
.Ar module .
Packit 08bd4c
.El
Packit 08bd4c
The currently supported modules and keys are:
Packit 08bd4c
.Bl -tag -compact -width indent
Packit 08bd4c
.It Cm iso9660:joliet
Packit 08bd4c
Support Joliet extensions.
Packit 08bd4c
This is enabled by default, use
Packit 08bd4c
.Cm !joliet
Packit 08bd4c
or
Packit 08bd4c
.Cm iso9660:!joliet
Packit 08bd4c
to disable.
Packit 08bd4c
.It Cm iso9660:rockridge
Packit 08bd4c
Support Rock Ridge extensions.
Packit 08bd4c
This is enabled by default, use
Packit 08bd4c
.Cm !rockridge
Packit 08bd4c
or
Packit 08bd4c
.Cm iso9660:!rockridge
Packit 08bd4c
to disable.
Packit 08bd4c
.It Cm gzip:compression-level
Packit 08bd4c
A decimal integer from 1 to 9 specifying the gzip compression level.
Packit 08bd4c
.It Cm gzip:timestamp
Packit 08bd4c
Store timestamp. This is enabled by default, use
Packit 08bd4c
.Cm !timestamp
Packit 08bd4c
or
Packit 08bd4c
.Cm gzip:!timestamp
Packit 08bd4c
to disable.
Packit 08bd4c
.It Cm lrzip:compression Ns = Ns Ar type
Packit 08bd4c
Use
Packit 08bd4c
.Ar type
Packit 08bd4c
as compression method.
Packit 08bd4c
Supported values are bzip2, gzip, lzo (ultra fast),
Packit 08bd4c
and zpaq (best, extremely slow).
Packit 08bd4c
.It Cm lrzip:compression-level
Packit 08bd4c
A decimal integer from 1 to 9 specifying the lrzip compression level.
Packit 08bd4c
.It Cm lz4:compression-level
Packit 08bd4c
A decimal integer from 1 to 9 specifying the lzop compression level.
Packit 08bd4c
.It Cm lz4:stream-checksum
Packit 08bd4c
Enable stream checksum. This is by default, use
Packit 08bd4c
.Cm lz4:!stream-checksum
Packit 08bd4c
to disable.
Packit 08bd4c
.It Cm lz4:block-checksum
Packit 08bd4c
Enable block checksum (Disabled by default).
Packit 08bd4c
.It Cm lz4:block-size
Packit 08bd4c
A decimal integer from 4 to 7 specifying the lz4 compression block size
Packit 08bd4c
(7 is set by default).
Packit 08bd4c
.It Cm lz4:block-dependence
Packit 08bd4c
Use the previous block of the block being compressed for
Packit 08bd4c
a compression dictionary to improve compression ratio.
Packit 08bd4c
.It Cm lzop:compression-level
Packit 08bd4c
A decimal integer from 1 to 9 specifying the lzop compression level.
Packit 08bd4c
.It Cm xz:compression-level
Packit 08bd4c
A decimal integer from 0 to 9 specifying the xz compression level.
Packit 08bd4c
.It Cm mtree: Ns Ar keyword
Packit 08bd4c
The mtree writer module allows you to specify which mtree keywords
Packit 08bd4c
will be included in the output.
Packit 08bd4c
Supported keywords include:
Packit 08bd4c
.Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent ,
Packit 08bd4c
.Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 ,
Packit 08bd4c
.Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname .
Packit 08bd4c
The default is equivalent to:
Packit 08bd4c
.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
Packit 08bd4c
.It Cm mtree:all
Packit 08bd4c
Enables all of the above keywords.
Packit 08bd4c
You can also use
Packit 08bd4c
.Cm mtree:!all
Packit 08bd4c
to disable all keywords.
Packit 08bd4c
.It Cm mtree:use-set
Packit 08bd4c
Enable generation of
Packit 08bd4c
.Cm /set
Packit 08bd4c
lines in the output.
Packit 08bd4c
.It Cm mtree:indent
Packit 08bd4c
Produce human-readable output by indenting options and splitting lines
Packit 08bd4c
to fit into 80 columns.
Packit 08bd4c
.It Cm zip:compression Ns = Ns Ar type
Packit 08bd4c
Use
Packit 08bd4c
.Ar type
Packit 08bd4c
as compression method.
Packit 08bd4c
Supported values are store (uncompressed) and deflate (gzip algorithm).
Packit 08bd4c
.It Cm zip:encryption
Packit 08bd4c
Enable encryption using traditional zip encryption.
Packit 08bd4c
.It Cm zip:encryption Ns = Ns Ar type
Packit 08bd4c
Use
Packit 08bd4c
.Ar type
Packit 08bd4c
as encryption type.
Packit 08bd4c
Supported values are zipcrypt (traditional zip encryption),
Packit 08bd4c
aes128 (WinZip AES-128 encryption) and aes256 (WinZip AES-256 encryption).
Packit 08bd4c
.It Cm read_concatenated_archives
Packit 08bd4c
Ignore zeroed blocks in the archive, which occurs when multiple tar archives
Packit 08bd4c
have been concatenated together.  Without this option, only the contents of
Packit 08bd4c
the first concatenated archive would be read.  This option is comparable to
Packit 08bd4c
the
Packit 08bd4c
.Fl i , Fl Fl ignore-zeros
Packit 08bd4c
option of GNU tar.
Packit 08bd4c
.El
Packit 08bd4c
If a provided option is not supported by any module, that
Packit 08bd4c
is a fatal error.
Packit 08bd4c
.It Fl P , Fl Fl absolute-paths
Packit 08bd4c
Preserve pathnames.
Packit 08bd4c
By default, absolute pathnames (those that begin with a /
Packit 08bd4c
character) have the leading slash removed both when creating archives
Packit 08bd4c
and extracting from them.
Packit 08bd4c
Also,
Packit 08bd4c
.Nm
Packit 08bd4c
will refuse to extract archive entries whose pathnames contain
Packit 08bd4c
.Pa ..
Packit 08bd4c
or whose target directory would be altered by a symlink.
Packit 08bd4c
This option suppresses these behaviors.
Packit 08bd4c
.It Fl p , Fl Fl insecure , Fl Fl preserve-permissions
Packit 08bd4c
(x mode only)
Packit 08bd4c
Preserve file permissions.
Packit 08bd4c
Attempt to restore the full permissions, including owner, file modes, ACLs,
Packit 08bd4c
extended attributes and extended file flags, if available, for each item
Packit 08bd4c
extracted from the archive. This is te reverse of
Packit 08bd4c
.Fl Fl no-same-permissions
Packit 08bd4c
and the default if
Packit 08bd4c
.Nm
Packit 08bd4c
is being run by root and can be partially overridden by also specifying
Packit 08bd4c
.Fl Fl no-acls ,
Packit 08bd4c
.Fl Fl no-fflags ,
Packit 08bd4c
.Fl Fl no-mac-metadata
Packit 08bd4c
or
Packit 08bd4c
.Fl Fl no-xattrs .
Packit 08bd4c
.It Fl Fl passphrase Ar passphrase
Packit 08bd4c
The
Packit 08bd4c
.Pa passphrase
Packit 08bd4c
is used to extract or create an encrypted archive.
Packit 08bd4c
Currently, zip is the only supported format that supports encryption.
Packit 08bd4c
You shouldn't use this option unless you realize how insecure
Packit 08bd4c
use of this option is.
Packit 08bd4c
.It Fl Fl posix
Packit 08bd4c
(c, r, u mode only)
Packit 08bd4c
Synonym for
Packit 08bd4c
.Fl Fl format Ar pax
Packit 08bd4c
.It Fl q , Fl Fl fast-read
Packit 08bd4c
(x and t mode only)
Packit 08bd4c
Extract or list only the first archive entry that matches each pattern
Packit 08bd4c
or filename operand.
Packit 08bd4c
Exit as soon as each specified pattern or filename has been matched.
Packit 08bd4c
By default, the archive is always read to the very end, since
Packit 08bd4c
there can be multiple entries with the same name and, by convention,
Packit 08bd4c
later entries overwrite earlier entries.
Packit 08bd4c
This option is provided as a performance optimization.
Packit 08bd4c
.It Fl S
Packit 08bd4c
(x mode only)
Packit 08bd4c
Extract files as sparse files.
Packit 08bd4c
For every block on disk, check first if it contains only NULL bytes and seek
Packit 08bd4c
over it otherwise.
Packit 08bd4c
This works similar to the conv=sparse option of dd.
Packit 08bd4c
.It Fl s Ar pattern
Packit 08bd4c
Modify file or archive member names according to
Packit 08bd4c
.Pa pattern .
Packit 08bd4c
The pattern has the format
Packit 08bd4c
.Ar /old/new/ Ns Op ghHprRsS
Packit 08bd4c
where
Packit 08bd4c
.Ar old
Packit 08bd4c
is a basic regular expression,
Packit 08bd4c
.Ar new
Packit 08bd4c
is the replacement string of the matched part,
Packit 08bd4c
and the optional trailing letters modify
Packit 08bd4c
how the replacement is handled.
Packit 08bd4c
If
Packit 08bd4c
.Ar old
Packit 08bd4c
is not matched, the pattern is skipped.
Packit 08bd4c
Within
Packit 08bd4c
.Ar new ,
Packit 08bd4c
~ is substituted with the match, \e1 to \e9 with the content of
Packit 08bd4c
the corresponding captured group.
Packit 08bd4c
The optional trailing g specifies that matching should continue
Packit 08bd4c
after the matched part and stop on the first unmatched pattern.
Packit 08bd4c
The optional trailing s specifies that the pattern applies to the value
Packit 08bd4c
of symbolic links.
Packit 08bd4c
The optional trailing p specifies that after a successful substitution
Packit 08bd4c
the original path name and the new path name should be printed to
Packit 08bd4c
standard error.
Packit 08bd4c
Optional trailing H, R, or S characters suppress substitutions
Packit 08bd4c
for hardlink targets, regular filenames, or symlink targets,
Packit 08bd4c
respectively.
Packit 08bd4c
Optional trailing h, r, or s characters enable substitutions
Packit 08bd4c
for hardlink targets, regular filenames, or symlink targets,
Packit 08bd4c
respectively.
Packit 08bd4c
The default is
Packit 08bd4c
.Ar hrs
Packit 08bd4c
which applies substitutions to all names.
Packit 08bd4c
In particular, it is never necessary to specify h, r, or s.
Packit 08bd4c
.It Fl Fl same-owner
Packit 08bd4c
(x mode only)
Packit 08bd4c
Extract owner and group IDs.
Packit 08bd4c
This is the reverse of
Packit 08bd4c
.Fl Fl no-same-owner
Packit 08bd4c
and the default behavior if
Packit 08bd4c
.Nm
Packit 08bd4c
is run as root.
Packit 08bd4c
.It Fl Fl strip-components Ar count
Packit 08bd4c
Remove the specified number of leading path elements.
Packit 08bd4c
Pathnames with fewer elements will be silently skipped.
Packit 08bd4c
Note that the pathname is edited after checking inclusion/exclusion patterns
Packit 08bd4c
but before security checks.
Packit 08bd4c
.It Fl T Ar filename , Fl Fl files-from Ar filename
Packit 08bd4c
In x or t mode,
Packit 08bd4c
.Nm
Packit 08bd4c
will read the list of names to be extracted from
Packit 08bd4c
.Pa filename .
Packit 08bd4c
In c mode,
Packit 08bd4c
.Nm
Packit 08bd4c
will read names to be archived from
Packit 08bd4c
.Pa filename .
Packit 08bd4c
The special name
Packit 08bd4c
.Dq -C
Packit 08bd4c
on a line by itself will cause the current directory to be changed to
Packit 08bd4c
the directory specified on the following line.
Packit 08bd4c
Names are terminated by newlines unless
Packit 08bd4c
.Fl Fl null
Packit 08bd4c
is specified.
Packit 08bd4c
Note that
Packit 08bd4c
.Fl Fl null
Packit 08bd4c
also disables the special handling of lines containing
Packit 08bd4c
.Dq -C .
Packit 08bd4c
Note:  If you are generating lists of files using
Packit 08bd4c
.Xr find 1 ,
Packit 08bd4c
you probably want to use
Packit 08bd4c
.Fl n
Packit 08bd4c
as well.
Packit 08bd4c
.It Fl Fl totals
Packit 08bd4c
(c, r, u modes only)
Packit 08bd4c
After archiving all files, print a summary to stderr.
Packit 08bd4c
.It Fl U , Fl Fl unlink , Fl Fl unlink-first
Packit 08bd4c
(x mode only)
Packit 08bd4c
Unlink files before creating them.
Packit 08bd4c
This can be a minor performance optimization if most files
Packit 08bd4c
already exist, but can make things slower if most files
Packit 08bd4c
do not already exist.
Packit 08bd4c
This flag also causes
Packit 08bd4c
.Nm
Packit 08bd4c
to remove intervening directory symlinks instead of
Packit 08bd4c
reporting an error.
Packit 08bd4c
See the SECURITY section below for more details.
Packit 08bd4c
.It Fl Fl uid Ar id
Packit 08bd4c
Use the provided user id number and ignore the user
Packit 08bd4c
name from the archive.
Packit 08bd4c
On create, if
Packit 08bd4c
.Fl Fl uname
Packit 08bd4c
is not also specified, the user name will be set to
Packit 08bd4c
match the user id.
Packit 08bd4c
.It Fl Fl uname Ar name
Packit 08bd4c
Use the provided user name.
Packit 08bd4c
On extract, this overrides the user name in the archive;
Packit 08bd4c
if the provided user name does not exist on the system,
Packit 08bd4c
it will be ignored and the user id
Packit 08bd4c
(from the archive or from the
Packit 08bd4c
.Fl Fl uid
Packit 08bd4c
option)
Packit 08bd4c
will be used instead.
Packit 08bd4c
On create, this sets the user name that will be stored
Packit 08bd4c
in the archive;
Packit 08bd4c
the name is not verified against the system user database.
Packit 08bd4c
.It Fl Fl use-compress-program Ar program
Packit 08bd4c
Pipe the input (in x or t mode) or the output (in c mode) through
Packit 08bd4c
.Pa program
Packit 08bd4c
instead of using the builtin compression support.
Packit 08bd4c
.It Fl v , Fl Fl verbose
Packit 08bd4c
Produce verbose output.
Packit 08bd4c
In create and extract modes,
Packit 08bd4c
.Nm
Packit 08bd4c
will list each file name as it is read from or written to
Packit 08bd4c
the archive.
Packit 08bd4c
In list mode,
Packit 08bd4c
.Nm
Packit 08bd4c
will produce output similar to that of
Packit 08bd4c
.Xr ls 1 .
Packit 08bd4c
An additional
Packit 08bd4c
.Fl v
Packit 08bd4c
option will also provide ls-like details in create and extract mode.
Packit 08bd4c
.It Fl Fl version
Packit 08bd4c
Print version of
Packit 08bd4c
.Nm
Packit 08bd4c
and
Packit 08bd4c
.Nm libarchive ,
Packit 08bd4c
and exit.
Packit 08bd4c
.It Fl w , Fl Fl confirmation , Fl Fl interactive
Packit 08bd4c
Ask for confirmation for every action.
Packit 08bd4c
.It Fl X Ar filename , Fl Fl exclude-from Ar filename
Packit 08bd4c
Read a list of exclusion patterns from the specified file.
Packit 08bd4c
See
Packit 08bd4c
.Fl Fl exclude
Packit 08bd4c
for more information about the handling of exclusions.
Packit 08bd4c
.It Fl Fl xattrs
Packit 08bd4c
(c, r, u, x modes only)
Packit 08bd4c
Archive or extract extended attributes. This is the reverse of
Packit 08bd4c
.Fl Fl no-xattrs
Packit 08bd4c
and the default behavior in c, r, and u modes or if
Packit 08bd4c
.Nm
Packit 08bd4c
is run in x mode as root.
Packit 08bd4c
.It Fl y
Packit 08bd4c
(c mode only)
Packit 08bd4c
Compress the resulting archive with
Packit 08bd4c
.Xr bzip2 1 .
Packit 08bd4c
In extract or list modes, this option is ignored.
Packit 08bd4c
Note that, unlike other
Packit 08bd4c
.Nm tar
Packit 08bd4c
implementations, this implementation recognizes bzip2 compression
Packit 08bd4c
automatically when reading archives.
Packit 08bd4c
.It Fl Z , Fl Fl compress , Fl Fl uncompress
Packit 08bd4c
(c mode only)
Packit 08bd4c
Compress the resulting archive with
Packit 08bd4c
.Xr compress 1 .
Packit 08bd4c
In extract or list modes, this option is ignored.
Packit 08bd4c
Note that, unlike other
Packit 08bd4c
.Nm tar
Packit 08bd4c
implementations, this implementation recognizes compress compression
Packit 08bd4c
automatically when reading archives.
Packit 08bd4c
.It Fl z , Fl Fl gunzip , Fl Fl gzip
Packit 08bd4c
(c mode only)
Packit 08bd4c
Compress the resulting archive with
Packit 08bd4c
.Xr gzip 1 .
Packit 08bd4c
In extract or list modes, this option is ignored.
Packit 08bd4c
Note that, unlike other
Packit 08bd4c
.Nm tar
Packit 08bd4c
implementations, this implementation recognizes gzip compression
Packit 08bd4c
automatically when reading archives.
Packit 08bd4c
.El
Packit 08bd4c
.Sh ENVIRONMENT
Packit 08bd4c
The following environment variables affect the execution of
Packit 08bd4c
.Nm :
Packit 08bd4c
.Bl -tag -width ".Ev BLOCKSIZE"
Packit 08bd4c
.It Ev TAR_READER_OPTIONS
Packit 08bd4c
The default options for format readers and compression readers.
Packit 08bd4c
The
Packit 08bd4c
.Fl Fl options
Packit 08bd4c
option overrides this.
Packit 08bd4c
.It Ev TAR_WRITER_OPTIONS
Packit 08bd4c
The default options for format writers and compression writers.
Packit 08bd4c
The
Packit 08bd4c
.Fl Fl options
Packit 08bd4c
option overrides this.
Packit 08bd4c
.It Ev LANG
Packit 08bd4c
The locale to use.
Packit 08bd4c
See
Packit 08bd4c
.Xr environ 7
Packit 08bd4c
for more information.
Packit 08bd4c
.It Ev TAPE
Packit 08bd4c
The default device.
Packit 08bd4c
The
Packit 08bd4c
.Fl f
Packit 08bd4c
option overrides this.
Packit 08bd4c
Please see the description of the
Packit 08bd4c
.Fl f
Packit 08bd4c
option above for more details.
Packit 08bd4c
.It Ev TZ
Packit 08bd4c
The timezone to use when displaying dates.
Packit 08bd4c
See
Packit 08bd4c
.Xr environ 7
Packit 08bd4c
for more information.
Packit 08bd4c
.El
Packit 08bd4c
.Sh EXIT STATUS
Packit 08bd4c
.Ex -std
Packit 08bd4c
.Sh EXAMPLES
Packit 08bd4c
The following creates a new archive
Packit 08bd4c
called
Packit 08bd4c
.Ar file.tar.gz
Packit 08bd4c
that contains two files
Packit 08bd4c
.Ar source.c
Packit 08bd4c
and
Packit 08bd4c
.Ar source.h :
Packit 08bd4c
.Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h
Packit 08bd4c
.Pp
Packit 08bd4c
To view a detailed table of contents for this
Packit 08bd4c
archive:
Packit 08bd4c
.Dl Nm Fl tvf Pa file.tar.gz
Packit 08bd4c
.Pp
Packit 08bd4c
To extract all entries from the archive on
Packit 08bd4c
the default tape drive:
Packit 08bd4c
.Dl Nm Fl x
Packit 08bd4c
.Pp
Packit 08bd4c
To examine the contents of an ISO 9660 cdrom image:
Packit 08bd4c
.Dl Nm Fl tf Pa image.iso
Packit 08bd4c
.Pp
Packit 08bd4c
To move file hierarchies, invoke
Packit 08bd4c
.Nm
Packit 08bd4c
as
Packit 08bd4c
.Dl Nm Fl cf Pa - Fl C Pa srcdir\ . | Nm Fl xpf Pa - Fl C Pa destdir
Packit 08bd4c
or more traditionally
Packit 08bd4c
.Dl cd srcdir \&; Nm Fl cf Pa -\ . | ( cd destdir \&; Nm Fl xpf Pa - )
Packit 08bd4c
.Pp
Packit 08bd4c
In create mode, the list of files and directories to be archived
Packit 08bd4c
can also include directory change instructions of the form
Packit 08bd4c
.Cm -C Ns Pa foo/baz
Packit 08bd4c
and archive inclusions of the form
Packit 08bd4c
.Cm @ Ns Pa archive-file .
Packit 08bd4c
For example, the command line
Packit 08bd4c
.Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2
Packit 08bd4c
will create a new archive
Packit 08bd4c
.Pa new.tar .
Packit 08bd4c
.Nm
Packit 08bd4c
will read the file
Packit 08bd4c
.Pa foo1
Packit 08bd4c
from the current directory and add it to the output archive.
Packit 08bd4c
It will then read each entry from
Packit 08bd4c
.Pa old.tgz
Packit 08bd4c
and add those entries to the output archive.
Packit 08bd4c
Finally, it will switch to the
Packit 08bd4c
.Pa /tmp
Packit 08bd4c
directory and add
Packit 08bd4c
.Pa foo2
Packit 08bd4c
to the output archive.
Packit 08bd4c
.Pp
Packit 08bd4c
An input file in
Packit 08bd4c
.Xr mtree 5
Packit 08bd4c
format can be used to create an output archive with arbitrary ownership,
Packit 08bd4c
permissions, or names that differ from existing data on disk:
Packit 08bd4c
.Pp
Packit 08bd4c
.Bd -literal -offset indent
Packit 08bd4c
$ cat input.mtree
Packit 08bd4c
#mtree
Packit 08bd4c
usr/bin uid=0 gid=0 mode=0755 type=dir
Packit 08bd4c
usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls
Packit 08bd4c
$ tar -cvf output.tar @input.mtree
Packit 08bd4c
.Ed
Packit 08bd4c
.Pp
Packit 08bd4c
The
Packit 08bd4c
.Fl Fl newer
Packit 08bd4c
and
Packit 08bd4c
.Fl Fl newer-mtime
Packit 08bd4c
switches accept a variety of common date and time specifications, including
Packit 08bd4c
.Dq 12 Mar 2005 7:14:29pm ,
Packit 08bd4c
.Dq 2005-03-12 19:14 ,
Packit 08bd4c
.Dq 5 minutes ago ,
Packit 08bd4c
and
Packit 08bd4c
.Dq 19:14 PST May 1 .
Packit 08bd4c
.Pp
Packit 08bd4c
The
Packit 08bd4c
.Fl Fl options
Packit 08bd4c
argument can be used to control various details of archive generation
Packit 08bd4c
or reading.
Packit 08bd4c
For example, you can generate mtree output which only contains
Packit 08bd4c
.Cm type , Cm time ,
Packit 08bd4c
and
Packit 08bd4c
.Cm uid
Packit 08bd4c
keywords:
Packit 08bd4c
.Dl Nm Fl cf Pa file.tar Fl Fl format=mtree Fl Fl options='!all,type,time,uid' Pa dir
Packit 08bd4c
or you can set the compression level used by gzip or xz compression:
Packit 08bd4c
.Dl Nm Fl czf Pa file.tar Fl Fl options='compression-level=9' .
Packit 08bd4c
For more details, see the explanation of the
Packit 08bd4c
.Fn archive_read_set_options
Packit 08bd4c
and
Packit 08bd4c
.Fn archive_write_set_options
Packit 08bd4c
API calls that are described in
Packit 08bd4c
.Xr archive_read 3
Packit 08bd4c
and
Packit 08bd4c
.Xr archive_write 3 .
Packit 08bd4c
.Sh COMPATIBILITY
Packit 08bd4c
The bundled-arguments format is supported for compatibility
Packit 08bd4c
with historic implementations.
Packit 08bd4c
It consists of an initial word (with no leading - character) in which
Packit 08bd4c
each character indicates an option.
Packit 08bd4c
Arguments follow as separate words.
Packit 08bd4c
The order of the arguments must match the order
Packit 08bd4c
of the corresponding characters in the bundled command word.
Packit 08bd4c
For example,
Packit 08bd4c
.Dl Nm Cm tbf 32 Pa file.tar
Packit 08bd4c
specifies three flags
Packit 08bd4c
.Cm t ,
Packit 08bd4c
.Cm b ,
Packit 08bd4c
and
Packit 08bd4c
.Cm f .
Packit 08bd4c
The
Packit 08bd4c
.Cm b
Packit 08bd4c
and
Packit 08bd4c
.Cm f
Packit 08bd4c
flags both require arguments,
Packit 08bd4c
so there must be two additional items
Packit 08bd4c
on the command line.
Packit 08bd4c
The
Packit 08bd4c
.Ar 32
Packit 08bd4c
is the argument to the
Packit 08bd4c
.Cm b
Packit 08bd4c
flag, and
Packit 08bd4c
.Ar file.tar
Packit 08bd4c
is the argument to the
Packit 08bd4c
.Cm f
Packit 08bd4c
flag.
Packit 08bd4c
.Pp
Packit 08bd4c
The mode options c, r, t, u, and x and the options
Packit 08bd4c
b, f, l, m, o, v, and w comply with SUSv2.
Packit 08bd4c
.Pp
Packit 08bd4c
For maximum portability, scripts that invoke
Packit 08bd4c
.Nm tar
Packit 08bd4c
should use the bundled-argument format above, should limit
Packit 08bd4c
themselves to the
Packit 08bd4c
.Cm c ,
Packit 08bd4c
.Cm t ,
Packit 08bd4c
and
Packit 08bd4c
.Cm x
Packit 08bd4c
modes, and the
Packit 08bd4c
.Cm b ,
Packit 08bd4c
.Cm f ,
Packit 08bd4c
.Cm m ,
Packit 08bd4c
.Cm v ,
Packit 08bd4c
and
Packit 08bd4c
.Cm w
Packit 08bd4c
options.
Packit 08bd4c
.Pp
Packit 08bd4c
Additional long options are provided to improve compatibility with other
Packit 08bd4c
tar implementations.
Packit 08bd4c
.Sh SECURITY
Packit 08bd4c
Certain security issues are common to many archiving programs, including
Packit 08bd4c
.Nm .
Packit 08bd4c
In particular, carefully-crafted archives can request that
Packit 08bd4c
.Nm
Packit 08bd4c
extract files to locations outside of the target directory.
Packit 08bd4c
This can potentially be used to cause unwitting users to overwrite
Packit 08bd4c
files they did not intend to overwrite.
Packit 08bd4c
If the archive is being extracted by the superuser, any file
Packit 08bd4c
on the system can potentially be overwritten.
Packit 08bd4c
There are three ways this can happen.
Packit 08bd4c
Although
Packit 08bd4c
.Nm
Packit 08bd4c
has mechanisms to protect against each one,
Packit 08bd4c
savvy users should be aware of the implications:
Packit 08bd4c
.Bl -bullet -width indent
Packit 08bd4c
.It
Packit 08bd4c
Archive entries can have absolute pathnames.
Packit 08bd4c
By default,
Packit 08bd4c
.Nm
Packit 08bd4c
removes the leading
Packit 08bd4c
.Pa /
Packit 08bd4c
character from filenames before restoring them to guard against this problem.
Packit 08bd4c
.It
Packit 08bd4c
Archive entries can have pathnames that include
Packit 08bd4c
.Pa ..
Packit 08bd4c
components.
Packit 08bd4c
By default,
Packit 08bd4c
.Nm
Packit 08bd4c
will not extract files containing
Packit 08bd4c
.Pa ..
Packit 08bd4c
components in their pathname.
Packit 08bd4c
.It
Packit 08bd4c
Archive entries can exploit symbolic links to restore
Packit 08bd4c
files to other directories.
Packit 08bd4c
An archive can restore a symbolic link to another directory,
Packit 08bd4c
then use that link to restore a file into that directory.
Packit 08bd4c
To guard against this,
Packit 08bd4c
.Nm
Packit 08bd4c
checks each extracted path for symlinks.
Packit 08bd4c
If the final path element is a symlink, it will be removed
Packit 08bd4c
and replaced with the archive entry.
Packit 08bd4c
If
Packit 08bd4c
.Fl U
Packit 08bd4c
is specified, any intermediate symlink will also be unconditionally removed.
Packit 08bd4c
If neither
Packit 08bd4c
.Fl U
Packit 08bd4c
nor
Packit 08bd4c
.Fl P
Packit 08bd4c
is specified,
Packit 08bd4c
.Nm
Packit 08bd4c
will refuse to extract the entry.
Packit 08bd4c
.El
Packit 08bd4c
To protect yourself, you should be wary of any archives that
Packit 08bd4c
come from untrusted sources.
Packit 08bd4c
You should examine the contents of an archive with
Packit 08bd4c
.Dl Nm Fl tf Pa filename
Packit 08bd4c
before extraction.
Packit 08bd4c
You should use the
Packit 08bd4c
.Fl k
Packit 08bd4c
option to ensure that
Packit 08bd4c
.Nm
Packit 08bd4c
will not overwrite any existing files or the
Packit 08bd4c
.Fl U
Packit 08bd4c
option to remove any pre-existing files.
Packit 08bd4c
You should generally not extract archives while running with super-user
Packit 08bd4c
privileges.
Packit 08bd4c
Note that the
Packit 08bd4c
.Fl P
Packit 08bd4c
option to
Packit 08bd4c
.Nm
Packit 08bd4c
disables the security checks above and allows you to extract
Packit 08bd4c
an archive while preserving any absolute pathnames,
Packit 08bd4c
.Pa ..
Packit 08bd4c
components, or symlinks to other directories.
Packit 08bd4c
.Sh SEE ALSO
Packit 08bd4c
.Xr bzip2 1 ,
Packit 08bd4c
.Xr compress 1 ,
Packit 08bd4c
.Xr cpio 1 ,
Packit 08bd4c
.Xr gzip 1 ,
Packit 08bd4c
.Xr mt 1 ,
Packit 08bd4c
.Xr pax 1 ,
Packit 08bd4c
.Xr shar 1 ,
Packit 08bd4c
.Xr xz 1 ,
Packit 08bd4c
.Xr libarchive 3 ,
Packit 08bd4c
.Xr libarchive-formats 5 ,
Packit 08bd4c
.Xr tar 5
Packit 08bd4c
.Sh STANDARDS
Packit 08bd4c
There is no current POSIX standard for the tar command; it appeared
Packit 08bd4c
in
Packit 08bd4c
.St -p1003.1-96
Packit 08bd4c
but was dropped from
Packit 08bd4c
.St -p1003.1-2001 .
Packit 08bd4c
The options supported by this implementation were developed by surveying a
Packit 08bd4c
number of existing tar implementations as well as the old POSIX specification
Packit 08bd4c
for tar and the current POSIX specification for pax.
Packit 08bd4c
.Pp
Packit 08bd4c
The ustar and pax interchange file formats are defined by
Packit 08bd4c
.St -p1003.1-2001
Packit 08bd4c
for the pax command.
Packit 08bd4c
.Sh HISTORY
Packit 08bd4c
A
Packit 08bd4c
.Nm tar
Packit 08bd4c
command appeared in Seventh Edition Unix, which was released in January, 1979.
Packit 08bd4c
There have been numerous other implementations,
Packit 08bd4c
many of which extended the file format.
Packit 08bd4c
John Gilmore's
Packit 08bd4c
.Nm pdtar
Packit 08bd4c
public-domain implementation (circa November, 1987)
Packit 08bd4c
was quite influential, and formed the basis of GNU tar.
Packit 08bd4c
GNU tar was included as the standard system tar
Packit 08bd4c
in
Packit 08bd4c
.Fx
Packit 08bd4c
beginning with
Packit 08bd4c
.Fx 1.0 .
Packit 08bd4c
.Pp
Packit 08bd4c
This is a complete re-implementation based on the
Packit 08bd4c
.Xr libarchive 3
Packit 08bd4c
library.
Packit 08bd4c
It was first released with
Packit 08bd4c
.Fx 5.4
Packit 08bd4c
in May, 2005.
Packit 08bd4c
.Sh BUGS
Packit 08bd4c
This program follows
Packit 08bd4c
.St -p1003.1-96
Packit 08bd4c
for the definition of the
Packit 08bd4c
.Fl l
Packit 08bd4c
option.
Packit 08bd4c
Note that GNU tar prior to version 1.15 treated
Packit 08bd4c
.Fl l
Packit 08bd4c
as a synonym for the
Packit 08bd4c
.Fl Fl one-file-system
Packit 08bd4c
option.
Packit 08bd4c
.Pp
Packit 08bd4c
The
Packit 08bd4c
.Fl C Pa dir
Packit 08bd4c
option may differ from historic implementations.
Packit 08bd4c
.Pp
Packit 08bd4c
All archive output is written in correctly-sized blocks, even
Packit 08bd4c
if the output is being compressed.
Packit 08bd4c
Whether or not the last output block is padded to a full
Packit 08bd4c
block size varies depending on the format and the
Packit 08bd4c
output device.
Packit 08bd4c
For tar and cpio formats, the last block of output is padded
Packit 08bd4c
to a full block size if the output is being
Packit 08bd4c
written to standard output or to a character or block device such as
Packit 08bd4c
a tape drive.
Packit 08bd4c
If the output is being written to a regular file, the last block
Packit 08bd4c
will not be padded.
Packit 08bd4c
Many compressors, including
Packit 08bd4c
.Xr gzip 1
Packit 08bd4c
and
Packit 08bd4c
.Xr bzip2 1 ,
Packit 08bd4c
complain about the null padding when decompressing an archive created by
Packit 08bd4c
.Nm ,
Packit 08bd4c
although they still extract it correctly.
Packit 08bd4c
.Pp
Packit 08bd4c
The compression and decompression is implemented internally, so
Packit 08bd4c
there may be insignificant differences between the compressed output
Packit 08bd4c
generated by
Packit 08bd4c
.Dl Nm Fl czf Pa - file
Packit 08bd4c
and that generated by
Packit 08bd4c
.Dl Nm Fl cf Pa - file | Nm gzip
Packit 08bd4c
.Pp
Packit 08bd4c
The default should be to read and write archives to the standard I/O paths,
Packit 08bd4c
but tradition (and POSIX) dictates otherwise.
Packit 08bd4c
.Pp
Packit 08bd4c
The
Packit 08bd4c
.Cm r
Packit 08bd4c
and
Packit 08bd4c
.Cm u
Packit 08bd4c
modes require that the archive be uncompressed
Packit 08bd4c
and located in a regular file on disk.
Packit 08bd4c
Other archives can be modified using
Packit 08bd4c
.Cm c
Packit 08bd4c
mode with the
Packit 08bd4c
.Pa @archive-file
Packit 08bd4c
extension.
Packit 08bd4c
.Pp
Packit 08bd4c
To archive a file called
Packit 08bd4c
.Pa @foo
Packit 08bd4c
or
Packit 08bd4c
.Pa -foo
Packit 08bd4c
you must specify it as
Packit 08bd4c
.Pa ./@foo
Packit 08bd4c
or
Packit 08bd4c
.Pa ./-foo ,
Packit 08bd4c
respectively.
Packit 08bd4c
.Pp
Packit 08bd4c
In create mode, a leading
Packit 08bd4c
.Pa ./
Packit 08bd4c
is always removed.
Packit 08bd4c
A leading
Packit 08bd4c
.Pa /
Packit 08bd4c
is stripped unless the
Packit 08bd4c
.Fl P
Packit 08bd4c
option is specified.
Packit 08bd4c
.Pp
Packit 08bd4c
There needs to be better support for file selection on both create
Packit 08bd4c
and extract.
Packit 08bd4c
.Pp
Packit 08bd4c
There is not yet any support for multi-volume archives.
Packit 08bd4c
.Pp
Packit 08bd4c
Converting between dissimilar archive formats (such as tar and cpio) using the
Packit 08bd4c
.Cm @ Ns Pa -
Packit 08bd4c
convention can cause hard link information to be lost.
Packit 08bd4c
(This is a consequence of the incompatible ways that different archive
Packit 08bd4c
formats store hardlink information.)