Unless specifically stated otherwise, options are applicable in all operating modes.
@archive
(c and r modes only) The specified archive is opened and the entries in it will be appended to
the current archive. As a simple example,
tar-c-f-newfile@original.tar
writes a new archive to standard output containing a file newfile and all of the entries from
original.tar. In contrast,
tar-c-f-newfileoriginal.tar
creates a new archive with only two entries. Similarly,
tar-czf---formatpax@-
reads an archive from standard input (whose format will be determined automatically) and converts
it into a gzip-compressed pax-format archive on stdout. In this way, tar can be used to convert
archives from one format to another.
-a, --auto-compress
(c mode only) Use the archive suffix to decide a set of the format and the compressions. As a
simple example,
tar-a-cfarchive.tgzsource.csource.h
creates a new archive with restricted pax format and gzip compression,
tar-a-cfarchive.tar.bz2.uusource.csource.h
creates a new archive with restricted pax format and bzip2 compression and uuencode compression,
tar-a-cfarchive.zipsource.csource.h
creates a new archive with zip format,
tar-a-jcfarchive.tgzsource.csource.h
ignores the “-j” option, and creates a new archive with restricted pax format and gzip
compression,
tar-a-jcfarchive.xxxsource.csource.h
if it is unknown suffix or no suffix, creates a new archive with restricted pax format and bzip2
compression.
--acls (c, r, u, x modes only) Archive or extract POSIX.1e or NFSv4 ACLs. This is the reverse of
--no-acls and the default behavior in c, r, and u modes (except on Mac OS X) or if tar is run in
x mode as root. On Mac OS X this option translates extended ACLs to NFSv4 ACLs. To store
extended ACLs the --mac-metadata option is preferred.
-B, --read-full-blocks
Ignored for compatibility with other tar(1) implementations.
-bblocksize, --block-sizeblocksize
Specify the block size, in 512-byte records, for tape drive I/O. As a rule, this argument is
only needed when reading from or writing to tape drives, and usually not even then as the default
block size of 20 records (10240 bytes) is very common.
-Cdirectory, --cddirectory, --directorydirectory
In c and r mode, this changes the directory before adding the following files. In x mode, change
directories after opening the archive but before extracting entries from the archive.
--chroot
(x mode only) chroot() to the current directory after processing any -C options and before
extracting any files.
--clear-nochange-fflags
(x mode only) Before removing file system objects to replace them, clear platform-specific file
attributes or file flags that might prevent removal.
--excludepattern
Do not process files or directories that match the specified pattern. Note that exclusions take
precedence over patterns or filenames specified on the command line.
--exclude-vcs
Do not process files or directories internally used by the version control systems ‘Arch’,
‘Bazaar’, ‘CVS’, ‘Darcs’, ‘Mercurial’, ‘RCS’, ‘SCCS’, ‘SVN’ and ‘git’.
--fflags
(c, r, u, x modes only) Archive or extract platform-specific file attributes or file flags. This
is the reverse of --no-fflags and the default behavior in c, r, and u modes or if tar is run in x
mode as root.
--formatformat
(c, r, u mode only) Use the specified format for the created archive. Supported formats include
“cpio”, “pax”, “shar”, and “ustar”. Other formats may also be supported; see
libarchive-formats(5) for more information about currently-supported formats. In r and u modes,
when extending an existing archive, the format specified here must be compatible with the format
of the existing archive on disk.
-ffile, --filefile
Read the archive from or write the archive to the specified file. The filename can be - for
standard input or standard output. The default varies by system; on FreeBSD, the default is
/dev/sa0; on Linux, the default is /dev/st0.
--gidid
Use the provided group id number. On extract, this overrides the group id in the archive; the
group name in the archive will be ignored. On create, this overrides the group id read from
disk; if --gname is not also specified, the group name will be set to match the group id.
--gnamename
Use the provided group name. On extract, this overrides the group name in the archive; if the
provided group name does not exist on the system, the group id (from the archive or from the
--gid option) will be used instead. On create, this sets the group name that will be stored in
the archive; the name will not be verified against the system group database.
--groupname[:gid]
Use the provided group, if gid is not provided, name can be either a group name or numeric id.
See the --gname option for details.
-H (c and r modes only) Symbolic links named on the command line will be followed; the target of the
link will be archived, not the link itself.
-h (c and r modes only) Synonym for -L.
-I Synonym for -T.
--help Show usage.
--hfsCompression
(x mode only) Mac OS X specific (v10.6 or later). Compress extracted regular files with HFS+
compression.
--ignore-zeros
An alias of --optionsread_concatenated_archives for compatibility with GNU tar.
--includepattern
Process only files or directories that match the specified pattern. Note that exclusions
specified with --exclude take precedence over inclusions. If no inclusions are explicitly
specified, all entries are processed by default. The --include option is especially useful when
filtering archives. For example, the command
tar-c-fnew.tar--include='*foo*'@old.tgz
creates a new archive new.tar containing only the entries from old.tgz containing the string
‘foo’.
-J, --xz
(c mode only) Compress the resulting archive with xz(1). In extract or list modes, this option
is ignored. Note that this tar implementation recognizes XZ compression automatically when
reading archives.
-j, --bzip, --bzip2, --bunzip2
(c mode only) Compress the resulting archive with bzip2(1). In extract or list modes, this
option is ignored. Note that this tar implementation recognizes bzip2 compression automatically
when reading archives.
-k, --keep-old-files
(x mode only) Do not overwrite existing files. In particular, if a file appears more than once
in an archive, later copies will not overwrite earlier copies.
--keep-newer-files
(x mode only) Do not overwrite existing files that are newer than the versions appearing in the
archive being extracted.
-L, --dereference
(c and r modes only) All symbolic links will be followed. Normally, symbolic links are archived
as such. With this option, the target of the link will be archived instead.
-l, --check-links
(c and r modes only) Issue a warning message unless all links to each file are archived.
--lrzip
(c mode only) Compress the resulting archive with lrzip(1). In extract or list modes, this
option is ignored. Note that this tar implementation recognizes lrzip compression automatically
when reading archives.
--lz4 (c mode only) Compress the archive with lz4-compatible compression before writing it. In extract
or list modes, this option is ignored. Note that this tar implementation recognizes lz4
compression automatically when reading archives.
--zstd (c mode only) Compress the archive with zstd-compatible compression before writing it. In
extract or list modes, this option is ignored. Note that this tar implementation recognizes zstd
compression automatically when reading archives.
--lzma (c mode only) Compress the resulting archive with the original LZMA algorithm. In extract or
list modes, this option is ignored. Use of this option is discouraged and new archives should be
created with --xz instead. Note that this tar implementation recognizes LZMA compression
automatically when reading archives.
--lzop (c mode only) Compress the resulting archive with lzop(1). In extract or list modes, this option
is ignored. Note that this tar implementation recognizes LZO compression automatically when
reading archives.
-m, --modification-time
(x mode only) Do not extract modification time. By default, the modification time is set to the
time stored in the archive.
--mac-metadata
(c, r, u and x mode only) Mac OS X specific. Archive or extract extended ACLs and extended file
attributes using copyfile(3) in AppleDouble format. This is the reverse of --no-mac-metadata.
and the default behavior in c, r, and u modes or if tar is run in x mode as root. Currently
supported only for pax formats (including "pax restricted", the default tar format for bsdtar.)
-n, --norecurse, --no-recursion
Do not operate recursively on the content of directories.
--newerdate
(c, r, u modes only) Only include files and directories newer than the specified date. This
compares ctime entries.
--newer-mtimedate
(c, r, u modes only) Like --newer, except it compares mtime entries instead of ctime entries.
--newer-thanfile
(c, r, u modes only) Only include files and directories newer than the specified file. This
compares ctime entries.
--newer-mtime-thanfile
(c, r, u modes only) Like --newer-than, except it compares mtime entries instead of ctime
entries.
--nodump
(c and r modes only) Honor the nodump file flag by skipping this file.
--nopreserveHFSCompression
(x mode only) Mac OS X specific (v10.6 or later). Do not compress extracted regular files which
were compressed with HFS+ compression before archived. By default, compress the regular files
again with HFS+ compression.
--null (use with -I or -T) Filenames or patterns are separated by null characters, not by newlines.
This is often used to read filenames output by the -print0 option to find(1).
--no-acls
(c, r, u, x modes only) Do not archive or extract POSIX.1e or NFSv4 ACLs. This is the reverse of
--acls and the default behavior if tar is run as non-root in x mode (on Mac OS X as any user in
c, r, u and x modes).
--no-fflags
(c, r, u, x modes only) Do not archive or extract file attributes or file flags. This is the
reverse of --fflags and the default behavior if tar is run as non-root in x mode.
--no-mac-metadata
(x mode only) Mac OS X specific. Do not archive or extract ACLs and extended file attributes
using copyfile(3) in AppleDouble format. This is the reverse of --mac-metadata. and the default
behavior if tar is run as non-root in x mode.
--no-read-sparse
(c, r, u modes only) Do not read sparse file information from disk. This is the reverse of
--read-sparse.
--no-safe-writes
(x mode only) Do not create temporary files and use rename(2) to replace the original ones. This
is the reverse of --safe-writes.
--no-same-owner
(x mode only) Do not extract owner and group IDs. This is the reverse of --same-owner and the
default behavior if tar is run as non-root.
--no-same-permissions
(x mode only) Do not extract full permissions (SGID, SUID, sticky bit, file attributes or file
flags, extended file attributes and ACLs). This is the reverse of -p and the default behavior if
tar is run as non-root.
--no-xattrs
(c, r, u, x modes only) Do not archive or extract extended file attributes. This is the reverse
of --xattrs and the default behavior if tar is run as non-root in x mode.
--numeric-owner
This is equivalent to --uname "" --gname "". On extract, it causes user and group names in the
archive to be ignored in favor of the numeric user and group ids. On create, it causes user and
group names to not be stored in the archive.
-O, --to-stdout
(x, t modes only) In extract (-x) mode, files will be written to standard out rather than being
extracted to disk. In list (-t) mode, the file listing will be written to stderr rather than the
usual stdout.
-o (x mode) Use the user and group of the user running the program rather than those specified in
the archive. Note that this has no significance unless -p is specified, and the program is being
run by the root user. In this case, the file modes and flags from the archive will be restored,
but ACLs or owner information in the archive will be discarded.
-o (c, r, u mode) A synonym for --formatustar--olderdate
(c, r, u modes only) Only include files and directories older than the specified date. This
compares ctime entries.
--older-mtimedate
(c, r, u modes only) Like --older, except it compares mtime entries instead of ctime entries.
--older-thanfile
(c, r, u modes only) Only include files and directories older than the specified file. This
compares ctime entries.
--older-mtime-thanfile
(c, r, u modes only) Like --older-than, except it compares mtime entries instead of ctime
entries.
--one-file-system
(c, r, and u modes) Do not cross mount points.
--optionsoptions
Select optional behaviors for particular modules. The argument is a text string containing
comma-separated keywords and values. These are passed to the modules that handle particular
formats to control how those formats will behave. Each option has one of the following forms:
key=value
The key will be set to the specified value in every module that supports it. Modules
that do not support this key will ignore it.
key The key will be enabled in every module that supports it. This is equivalent to key=1.
!key The key will be disabled in every module that supports it.
module:key=value, module:key, module:!key
As above, but the corresponding key and value will be provided only to modules whose name
matches module.
The complete list of supported modules and keys for create and append modes is in
archive_write_set_options(3) and for extract and list modes in archive_read_set_options(3).
Examples of supported options:
iso9660:joliet
Support Joliet extensions. This is enabled by default, use !joliet or iso9660:!joliet to
disable.
iso9660:rockridge
Support Rock Ridge extensions. This is enabled by default, use !rockridge or
iso9660:!rockridge to disable.
gzip:compression-level
A decimal integer from 1 to 9 specifying the gzip compression level.
gzip:timestamp
Store timestamp. This is enabled by default, use !timestamp or gzip:!timestamp to
disable.
lrzip:compression=type
Use type as compression method. Supported values are bzip2, gzip, lzo (ultra fast), and
zpaq (best, extremely slow).
lrzip:compression-level
A decimal integer from 1 to 9 specifying the lrzip compression level.
lz4:compression-level
A decimal integer from 1 to 9 specifying the lzop compression level.
lz4:stream-checksum
Enable stream checksum. This is by default, use lz4:!stream-checksum to disable.
lz4:block-checksum
Enable block checksum (Disabled by default).
lz4:block-size
A decimal integer from 4 to 7 specifying the lz4 compression block size (7 is set by
default).
lz4:block-dependence
Use the previous block of the block being compressed for a compression dictionary to
improve compression ratio.
zstd:compression-level=N
A decimal integer specifying the zstd compression level. Supported values depend on the
library version, common values are from 1 to 22.
zstd:threads=N
Specify the number of worker threads to use, or 0 to use as many threads as there are CPU
cores in the system.
zstd:frame-per-file
Start a new compression frame at the beginning of each file in the archive.
zstd:min-frame-in=N
In combination with zstd:frame-per-file, do not start a new compression frame unless the
uncompressed size of the current frame is at least N bytes. The number may be followed
by k/kB, M/MB, or G/GB to indicate kilobytes, megabytes or gigabytes respectively.
zstd:min-frame-out=N, zstd:min-frame-size=N
In combination with zstd:frame-per-file, do not start a new compression frame unless the
compressed size of the current frame is at least N bytes. The number may be followed by
k/kB, M/MB, or G/GB to indicate kilobytes, megabytes or gigabytes respectively.
zstd:max-frame-in=N, zstd:max-frame-size=N
Start a new compression frame as soon as possible after the uncompressed size of the
current frame exceeds N bytes. The number may be followed by k/kB, M/MB, or G/GB
to indicate kilobytes, megabytes or gigabytes respectively. Values less than 1,024 will
be rejected.
zstd:max-frame-out=N
Start a new compression frame as soon as possible after the compressed size of the
current frame exceeds N bytes. The number may be followed by k/kB, M/MB, or G/GB
to indicate kilobytes, megabytes or gigabytes respectively. Values less than 1,024 will
be rejected.
lzop:compression-level
A decimal integer from 1 to 9 specifying the lzop compression level.
xz:compression-level
A decimal integer from 0 to 9 specifying the xz compression level.
xz:threads
Specify the number of worker threads to use. Setting threads to a special value 0 makes
xz(1) use as many threads as there are CPU cores on the system.
mtree:keyword
The mtree writer module allows you to specify which mtree keywords will be included in
the output. Supported keywords include: cksum, device, flags, gid, gname, indent, link,
md5, mode, nlink, rmd160, sha1, sha256, sha384, sha512, size, time, uid, uname. The
default is equivalent to: “device, flags, gid, gname, link, mode, nlink, size, time,
type, uid, uname”.
mtree:all
Enables all of the above keywords. You can also use mtree:!all to disable all keywords.
mtree:use-set
Enable generation of /set lines in the output.
mtree:indent
Produce human-readable output by indenting options and splitting lines to fit into 80
columns.
zip:compression=type
Use type as compression method. Supported values are store (uncompressed) and deflate
(gzip algorithm).
zip:encryption
Enable encryption using traditional zip encryption.
zip:encryption=type
Use type as encryption type. Supported values are zipcrypt (traditional zip encryption),
aes128 (WinZip AES-128 encryption) and aes256 (WinZip AES-256 encryption).
read_concatenated_archives
Ignore zeroed blocks in the archive, which occurs when multiple tar archives have been
concatenated together. Without this option, only the contents of the first concatenated
archive would be read. This option is comparable to the -i, --ignore-zeros option of GNU
tar.
If a provided option is not supported by any module, that is a fatal error.
-P, --absolute-paths
Preserve pathnames. By default, absolute pathnames (those that begin with a / character) have
the leading slash removed both when creating archives and extracting from them. Also, tar will
refuse to extract archive entries whose pathnames contain .. or whose target directory would be
altered by a symlink. This option suppresses these behaviors.
-p, --insecure, --preserve-permissions
(x mode only) Preserve file permissions. Attempt to restore the full permissions, including file
modes, file attributes or file flags, extended file attributes and ACLs, if available, for each
item extracted from the archive. This is the reverse of --no-same-permissions and the default if
tar is being run as root. It can be partially overridden by also specifying --no-acls,
--no-fflags, --no-mac-metadata or --no-xattrs.
--passphrasepassphrase
The passphrase is used to extract or create an encrypted archive. Currently, zip is the only
supported format that supports encryption. You shouldn't use this option unless you realize how
insecure use of this option is.
--posix
(c, r, u mode only) Synonym for --formatpax-q, --fast-read
(x and t mode only) Extract or list only the first archive entry that matches each pattern or
filename operand. Exit as soon as each specified pattern or filename has been matched. By
default, the archive is always read to the very end, since there can be multiple entries with the
same name and, by convention, later entries overwrite earlier entries. This option is provided
as a performance optimization.
--read-sparse
(c, r, u modes only) Read sparse file information from disk. This is the reverse of
--no-read-sparse and the default behavior.
-S (x mode only) Extract files as sparse files. For every block on disk, check first if it contains
only NULL bytes and seek over it otherwise. This works similar to the conv=sparse option of dd.
-spattern
Modify file or archive member names according to pattern. The pattern has the format
/old/new/[bghHprRsS] where old is a basic regular expression, new is the replacement string of
the matched part, and the optional trailing letters modify how the replacement is handled. If
old is not matched, the pattern is skipped. Within new, ~ is substituted with the match, \1 to
\9 with the content of the corresponding captured group. The optional trailing g specifies that
matching should continue after the matched part and stop on the first unmatched pattern. The
optional trailing s specifies that the pattern applies to the value of symbolic links. The
optional trailing p specifies that after a successful substitution the original path name and the
new path name should be printed to standard error. The optional trailing b specifies that the
substitution should be matched from the beginning of the string rather than from right after the
position at which the previous matching substitution ended. Optional trailing H, R, or S
characters suppress substitutions for hardlink targets, regular filenames, or symlink targets,
respectively. Optional trailing h, r, or s characters enable substitutions for hardlink targets,
regular filenames, or symlink targets, respectively. The default is hrs which applies
substitutions to all names. In particular, it is never necessary to specify h, r, or s.
--safe-writes
(x mode only) Extract files atomically. By default tar unlinks the original file with the same
name as the extracted file (if it exists), and then creates it immediately under the same name
and writes to it. For a short period of time, applications trying to access the file might not
find it, or see incomplete results. If --safe-writes is enabled, tar first creates a unique
temporary file, then writes the new contents to the temporary file, and finally renames the
temporary file to its final name atomically using rename(2). This guarantees that an application
accessing the file, will either see the old contents or the new contents at all times.
--same-owner
(x mode only) Extract owner and group IDs. This is the reverse of --no-same-owner and the
default behavior if tar is run as root.
--strip-componentscount
Remove the specified number of leading path elements. Pathnames with fewer elements will be
silently skipped. Note that the pathname is edited after checking inclusion/exclusion patterns
but before security checks.
-Tfilename, --files-fromfilename
In x or t mode, tar will read the list of names to be extracted from filename. In c mode, tar
will read names to be archived from filename. The special name “-C” on a line by itself will
cause the current directory to be changed to the directory specified on the following line.
Names are terminated by newlines unless --null is specified. Note that --null also disables the
special handling of lines containing “-C”. Note: If you are generating lists of files using
find(1), you probably want to use -n as well.
--totals
(c, r, u modes only) After archiving all files, print a summary to stderr.
-U, --unlink, --unlink-first
(x mode only) Unlink files before creating them. This can be a minor performance optimization if
most files already exist, but can make things slower if most files do not already exist. This
flag also causes tar to remove intervening directory symlinks instead of reporting an error. See
the SECURITY section below for more details.
--uidid
Use the provided user id number and ignore the user name from the archive. On create, if --uname
is not also specified, the user name will be set to match the user id.
--unamename
Use the provided user name. On extract, this overrides the user name in the archive; if the
provided user name does not exist on the system, it will be ignored and the user id (from the
archive or from the --uid option) will be used instead. On create, this sets the user name that
will be stored in the archive; the name is not verified against the system user database.
--use-compress-programprogram
Pipe the input (in x or t mode) or the output (in c mode) through program instead of using the
builtin compression support.
--ownername[:uid]
Use the provided user, if uid is not provided, name can be either an username or numeric id. See
the --uname option for details.
-v, --verbose
Produce verbose output. In create and extract modes, tar will list each file name as it is read
from or written to the archive. In list mode, tar will produce output similar to that of ls(1).
An additional -v option will also provide ls-like details in create and extract mode.
--version
Print version of tar and libarchive, and exit.
-w, --confirmation, --interactive
Ask for confirmation for every action.
-Xfilename, --exclude-fromfilename
Read a list of exclusion patterns from the specified file. See --exclude for more information
about the handling of exclusions.
--xattrs
(c, r, u, x modes only) Archive or extract extended file attributes. This is the reverse of
--no-xattrs and the default behavior in c, r, and u modes or if tar is run in x mode as root.
-y (c mode only) Compress the resulting archive with bzip2(1). In extract or list modes, this
option is ignored. Note that this tar implementation recognizes bzip2 compression automatically
when reading archives.
-Z, --compress, --uncompress
(c mode only) Compress the resulting archive with compress(1). In extract or list modes, this
option is ignored. Note that this tar implementation recognizes compress compression
automatically when reading archives.
-z, --gunzip, --gzip
(c mode only) Compress the resulting archive with gzip(1). In extract or list modes, this option
is ignored. Note that this tar implementation recognizes gzip compression automatically when
reading archives.