TAR(1)

NAME

tar - an archiving utility

SYNOPSIS

Traditional usage

    tar {c|x|t} [OPTION...] -f ARCHIVE [FILE...]
      

UNIX-style usage

tar -c [-f ARCHIVE] [OPTIONS] [FILE...]
tar -r [-f ARCHIVE] [OPTIONS] [FILE...]
tar -t [-f ARCHIVE] [OPTIONS] [MEMBER...]
tar -u [-f ARCHIVE] [OPTIONS] [FILE...]
tar -x [-f ARCHIVE] [OPTIONS] [MEMBER...]

GNU-style usage

tar {--catenate|--concatenate} [OPTIONS] --file ARCHIVE ARCHIVE...
tar --create [--file ARCHIVE] [OPTIONS] [FILE...]
tar {--diff|--compare} [--file ARCHIVE] [OPTIONS] [FILE...]
tar --delete [--file ARCHIVE] [OPTIONS] [MEMBER...]
tar --append [--file ARCHIVE] [OPTIONS] [FILE...]
tar --list [--file ARCHIVE] [OPTIONS] [MEMBER...]
tar --test-label [--file ARCHIVE] [OPTIONS] [LABEL...]
tar --update [--file ARCHIVE] [OPTIONS] [FILE...]
tar {--extract|--get} [--file ARCHIVE] [OPTIONS] [MEMBER...]

NOTE

This manpage is a short description of GNU tar. For a detailed discussion, including examples and usage recommendations, refer to the GNU Tar Manual available in texinfo format. If the info reader and the tar documentation are properly installed on your system, the command


info tar

should give you access to the complete manual.

You can also view the manual using the info mode in emacs(1), or find it in various formats online at:

https://www.gnu.org/software/tar/manual

If any discrepancies occur between this manpage and the GNU Tar Manual, the later shall be considered the authoritative source.

DESCRIPTION

GNU tar is an archiving program designed to store multiple files in a single file (an archive), and to manipulate such archives. The archive can be either a regular file or a device (e.g. a tape drive, hence the name of the program, which stands for tape archiver), which can be located either on the local or on a remote machine.

Option styles

Options to GNU tar can be given in three different styles. In traditional style, the first argument is a cluster of option letters and all subsequent arguments supply parameters to those options that require them. The arguments are read in the same order as the option letters. Any command line words that remain after all options have been processed are treated as non-optional arguments: file or archive member names.

For example, the c option requires creating the archive, the v option requests verbose output, and the f option takes an argument that sets the name of the archive. The following command, written in traditional style, instructs tar to store all files from the directory /etc into the archive file etc.tar while listing the files being archived:

tar cfv etc.tar /etc

In UNIX (short-option) style, each option letter is prefixed with a single dash, as in other command-line utilities. If an option takes an argument, the argument follows it, either as a separate word or immediately after the option. However, if the option takes an optional argument, it must follow the option letter without any intervening whitespace, as in -g/tmp/snar.db.

Any number of options not taking arguments can be clustered together after a single dash (e.g. -vkp). Options that take arguments (whether mandatory or optional) can appear at the end of such a cluster (e.g. -vkpf a.tar).

The example command above written in short-option style could look like:

    tar -cvf etc.tar /etc
    tar -c -v -f etc.tar /etc
  

In GNU (long-option) style, each option begins with two dashes and has a meaningful name consisting of lowercase letters and dashes. Long options can be abbreviated to their initial letters, provided this does not create ambiguity. Arguments to long options are supplied either as a separate command-line word or separated from the option by an equals sign with no intervening whitespace. Optional arguments must always use the latter method.

Here are several ways of writing the example command in this style:

    tar --create --file etc.tar --verbose /etc
    tar --cre --file=etc.tar --verb /etc
  

The options in all three styles can be intermixed, although doing so with traditional options is not encouraged.

Operation mode

The options listed in the table below tell GNU tar what operation it is to perform. Exactly one of them must be given. Meaning of non-optional arguments depends on the operation mode requested.

-A, --catenate, --concatenate
Append archives to the end of another archive. The arguments are treated as names of archives to append. All archives must be of the same format as the target archive, otherwise the result may be unusable with non-GNU tar. When multiple archives are given, members from all but the first are only accessible when using -i (--ignore-zeros).

Compressed archives cannot be concatenated.
-c, --create
Create a new archive. Arguments specify the files to include. Directories are archived recursively unless --no-recursion is used.
-d, --diff, --compare
Find differences between the archive and the file system. Arguments are optional and specify archive members to compare. If omitted, the current directory is used.
--delete
Delete members from the archive. Arguments specify the names of members to remove. At least one argument is required.

This option does not work on compressed archives. No short option exists.
-r, --append
Append files to the end of an archive. Arguments behave the same as for -c (--create).
-t, --list
List archive contents. Arguments are optional and specify which members to list.
--test-label
Test the archive volume label and exit. Without arguments, prints the label (if any) and exits with status 0. With arguments, compares the label against each one and exits with 0 if a match is found, otherwise 1. No output is shown unless used with -v (--verbose).

No short option exists.
-u, --update
Append files that are newer than their archived versions. Arguments are the same as for -c and -r. Newer files do not replace old ones; they are appended, so multiple versions of the same file may exist.
-x, --extract, --get
Extract files from an archive. Arguments are optional and specify which members to extract.
--show-defaults
Show built-in defaults for various tar options and exit. No arguments allowed.
-?, --help
Display a short help summary and exit. No arguments allowed.
--usage
Display a list of available options and exit. No arguments allowed.
--version
Print version and copyright information and exit.

Overwrite control

These options control tar actions when extracting a file over an existing copy on disk.

-k, --keep-old-files
Do not replace existing files when extracting.
--keep-newer-files
Do not replace existing files that are newer than their archive copies.
--keep-directory-symlink
Do not replace existing symbolic links to directories when extracting.
--no-overwrite-dir
Preserve metadata of existing directories.
--one-top-level[=DIR]
Extract all files into DIR, or, if no argument is given, into a subdirectory named after the archive (without standard compression suffixes recognized by --auto-compress).
--overwrite
Overwrite existing files when extracting.
--overwrite-dir
Overwrite metadata of existing directories when extracting (default).
--recursive-unlink
Recursively remove all files in a directory before extracting it.
--remove-files
Remove files from disk after adding them to the archive.
--skip-old-files
Do not replace existing files when extracting; silently skip them.
-U, --unlink-first
Remove each file before extracting over it.
-W, --verify
Verify the archive after writing it.

OPTIONS

Operation modifiers

--check-device
Check device numbers when creating incremental archives (default).
-g, --listed-incremental=FILE
Handle new GNU-format incremental backups. FILE is a snapshot file used to store metadata about changed files since the last dump.

If FILE does not exist, it is created and all files are archived (level 0 dump). For incremental level N, use a copy of the snapshot file from level N−1.

When listing or extracting, the contents of FILE are not used; it is only required syntactically. Common practice is to use /dev/null.
--hole-detection=METHOD
Detect holes in sparse files using METHOD. Implies --sparse. Valid values are seek (default) and raw, with automatic fallback.
-G, --incremental
Handle old GNU-format incremental backups.
--ignore-failed-read
Do not exit with a nonzero status on unreadable files.
--level=NUMBER
Set dump level for listed-incremental archives. Currently only --level=0 is meaningful; it truncates the snapshot file, forcing a full (level 0) dump.
-n, --seek
Assume the archive is seekable. Normally detected automatically. This option is useful when detection fails and applies only when reading archives (e.g. with --list or --extract).
--no-check-device
Do not check device numbers when creating incremental archives.
--no-seek
Assume the archive is not seekable.
--occurrence[=N]
Process only the Nth occurrence of each file in the archive. Valid only with --delete, --diff, --extract, or --list, and when a file list is provided (via command line or -T). Default is 1.
--restrict
Disable the use of some potentially harmful options.
--sparse-version=MAJOR[.MINOR]
Set the sparse file format version (implies --sparse). Valid values are 0.0, 0.1, and 1.0. See the GNU Tar manual, appendix “Sparse Formats” for details.
-S, --sparse
Handle sparse files efficiently. Detects files with unwritten (empty) regions and avoids storing those regions in the archive, reducing size.

Overwrite control

-k, --keep-old-files
Don't replace existing files when extracting.
--keep-newer-files
Don't replace existing files that are newer than their archive copies.
--keep-directory-symlink
Don't replace existing symlinks to directories when extracting.
--no-overwrite-dir
Preserve metadata of existing directories.
--one-top-level[=DIR]
Extract all files into DIR, or, if used without argument, into a subdirectory named by the base name of the archive (minus standard compression suffixes recognizable by --auto-compress).
--overwrite
Overwrite existing files when extracting.
--overwrite-dir
Overwrite metadata of existing directories when extracting (default).
--recursive-unlink
Recursively remove all files in the directory prior to extracting it.
--remove-files
Remove files from disk after adding them to the archive.
--skip-old-files
Don't replace existing files when extracting, silently skip over them.
-U, --unlink-first
Remove each file prior to extracting over it.
-W, --verify
Verify the archive after writing it.

Output stream selection

--ignore-command-error
Ignore subprocess exit codes.
--no-ignore-command-error
Treat non-zero exit codes of children as error (default).
-O, --to-stdout
Extract files to standard output.
--to-command=COMMAND

Pipe extracted files to COMMAND. The argument is the pathname of an external program, optionally with command line arguments. The program will be invoked and the contents of the file being extracted supplied to it on its standard input. Additional data will be supplied via the following environment variables:

TAR_FILETYPE
Type of the file.
f
Regular file
d
Directory
l
Symbolic link
h
Hard link
b
Block device
c
Character device
Currently only regular files are supported.
TAR_MODE
File mode, an octal number.
TAR_FILENAME
The name of the file.
TAR_REALNAME
Name of the file as stored in the archive.
TAR_UNAME
Name of the file owner.
TAR_GNAME
Name of the file owner group.
TAR_ATIME
Time of last access. It is a decimal number, representing seconds since the Epoch. If the archive provides times with nanosecond precision, the nanoseconds are appended to the timestamp after a decimal point.
TAR_MTIME
Time of last modification.
TAR_CTIME
Time of last status change.
TAR_SIZE
Size of the file.
TAR_UID
UID of the file owner.
TAR_GID
GID of the file owner.
Additional tar variables
Additionally, the following variables contain information about tar operation mode and the archive being processed:
TAR_VERSION
GNU tar version number.
TAR_ARCHIVE
The name of the archive tar is processing.
TAR_BLOCKING_FACTOR
Current blocking factor, i.e. number of 512-byte blocks in a record.
TAR_VOLUME
Ordinal number of the volume tar is processing (set if reading a multi-volume archive).
TAR_FORMAT
Format of the archive being processed. One of: gnu, oldgnu, posix, ustar, v7.
TAR_SUBCOMMAND
A short option (with a leading dash) describing the operation tar is executing.

Handling of file attributes

--atime-preserve[=METHOD]
Preserve access times on dumped files, either by restoring the times after reading (METHOD=replace, this is the default) or by not setting the times in the first place (METHOD=system).
--delay-directory-restore
Delay setting modification times and permissions of extracted directories until the end of extraction. Use this option when extracting from an archive which has unusual member ordering.
--group=NAME[:GID]

Force NAME as group for added files. If GID is not supplied, NAME can be either a user name or numeric GID. In this case the missing part (GID or name) will be inferred from the current host's group database.

When used with --group-map=FILE, affects only those files whose owner group is not listed in FILE.

--group-map=FILE

Read group translation map from FILE. Empty lines are ignored. Comments are introduced with # sign and extend to the end of line.

Each non-empty line in FILE defines translation for a single group. It must consist of two fields, delimited by any amount of whitespace:

OLDGRP NEWGRP[:NEWGID]

OLDGRP is either a valid group name or a GID prefixed with +. Unless NEWGID is supplied, NEWGRP must also be either a valid group name or a +GID. Otherwise, both NEWGRP and NEWGID need not be listed in the system group database.

As a result, each input file with owner group OLDGRP will be stored in archive with owner group NEWGRP and GID NEWGID.

--mode=CHANGES
Force symbolic mode CHANGES for added files.
--mtime=DATE-OR-FILE
Set mtime for added files. DATE-OR-FILE is either a date/time in almost arbitrary format, or the name of an existing file. In the latter case the mtime of that file will be used.
-m, --touch
Don't extract file modified time.
--no-delay-directory-restore
Cancel the effect of the prior --delay-directory-restore option.
--no-same-owner
Extract files as yourself (default for ordinary users).
--no-same-permissions
Apply the user's umask when extracting permissions from the archive (default for ordinary users).
--numeric-owner
Always use numbers for user/group names.
--owner=NAME[:UID]

Force NAME as owner for added files. If UID is not supplied, NAME can be either a user name or numeric UID. In this case the missing part (UID or name) will be inferred from the current host's user database.

When used with --owner-map=FILE, affects only those files whose owner is not listed in FILE.

--owner-map=FILE

Read owner translation map from FILE. Empty lines are ignored. Comments are introduced with # sign and extend to the end of line.

Each non-empty line in FILE defines translation for a single UID. It must consist of two fields, delimited by any amount of whitespace:

OLDUSR NEWUSR[:NEWUID]

OLDUSR is either a valid user name or a UID prefixed with +. Unless NEWUID is supplied, NEWUSR must also be either a valid user name or a +UID. Otherwise, both NEWUSR and NEWUID need not be listed in the system user database.

As a result, each input file owned by OLDUSR will be stored in archive with owner name NEWUSR and UID NEWUID.

-p, --preserve-permissions, --same-permissions
Extract information about file permissions (default for superuser).
--same-owner
Try extracting files with the same ownership as exists in the archive (default for superuser).
-s, --preserve-order, --same-order
Sort names to extract to match archive.
--sort=ORDER

When creating an archive, sort directory entries according to ORDER, which is one of none, name, or inode.

The default is --sort=none, which stores archive members in the same order as returned by the operating system.

Using --sort=name ensures the member ordering in the created archive is uniform and reproducible.

Using --sort=inode reduces the number of disk seeks made when creating the archive and thus can considerably speed up archivation. This sorting order is supported only if the underlying system provides the necessary information.

Extended file attributes

--acls
Enable POSIX ACLs support.
--no-acls
Disable POSIX ACLs support.
--selinux
Enable SELinux context support.
--no-selinux
Disable SELinux context support.
--xattrs
Enable extended attributes support.
--no-xattrs
Disable extended attributes support.
--xattrs-exclude=PATTERN
Specify the exclude pattern for xattr keys. PATTERN is a POSIX regular expression, e.g. --xattrs-exclude='^user.', to exclude attributes from the user namespace.
--xattrs-include=PATTERN
Specify the include pattern for xattr keys. PATTERN is a POSIX regular expression.

Device selection and switching

-f, --file=ARCHIVE

Use archive file or device ARCHIVE. If this option is not given, tar will first examine the environment variable TAPE. If it is set, its value will be used as the archive name. Otherwise, tar will assume the compiled-in default.

The default value can be inspected either using the --show-defaults option, or at the end of the tar --help output.

An archive name that has a colon in it specifies a file or device on a remote machine. The part before the colon is taken as the machine name or IP address, and the part after it as the file or device pathname, e.g.:

--file=remotehost:/dev/sr0

An optional username can be prefixed to the hostname, placing an @ sign between them.

By default, the remote host is accessed via the rsh(1) command. Nowadays it is common to use ssh(1) instead. You can do so by giving the following command line option:

--rsh-command=/usr/bin/ssh

The remote machine should have the rmt(8) command installed. If its pathname does not match tar's default, you can inform tar about the correct pathname using the --rmt-command option.

--force-local
Archive file is local even if it has a colon.
-F, --info-script=COMMAND, --new-volume-script=COMMAND

Run COMMAND at the end of each tape (implies -M). The command can include arguments.

When started, it will inherit tar's environment plus the following variables:

TAR_VERSION
GNU tar version number.
TAR_ARCHIVE
The name of the archive tar is processing.
TAR_BLOCKING_FACTOR
Current blocking factor, i.e. number of 512-byte blocks in a record.
TAR_VOLUME
Ordinal number of the volume tar is processing (set if reading a multi-volume archive).
TAR_FORMAT
Format of the archive being processed. One of: gnu, oldgnu, posix, ustar, v7.
TAR_SUBCOMMAND
A short option (with a leading dash) describing the operation tar is executing.
TAR_FD
File descriptor which can be used to communicate the new volume name to tar.

If the info script fails, tar exits; otherwise, it begins writing the next volume.

-L, --tape-length=N

Change tape after writing Nx1024 bytes.

If N is followed by a size suffix, the suffix specifies the multiplicative factor to be used instead of 1024.

This option implies -M.

-M, --multi-volume
Create/list/extract multi-volume archive.
--rmt-command=COMMAND
Use COMMAND instead of rmt when accessing remote archives. See the description of the -f option, above.
--rsh-command=COMMAND
Use COMMAND instead of rsh when accessing remote archives. See the description of the -f option, above.
--volno-file=FILE
When this option is used in conjunction with --multi-volume, tar will keep track of which volume of a multi-volume archive it is working in FILE.

Device blocking

-b, --blocking-factor=BLOCKS
Set record size to BLOCKSx512 bytes.
-B, --read-full-records
When listing or extracting, accept incomplete input records after end-of-file marker.
-i, --ignore-zeros

Ignore zeroed blocks in archive.

Normally two consecutive 512-blocks filled with zeroes mean EOF and tar stops reading after encountering them.

This option instructs it to read further and is useful when reading archives created with the -A option.

--record-size=NUMBER

Set record size. NUMBER is the number of bytes per record.

It must be multiple of 512.

It can be suffixed with a size suffix, e.g. --record-size=10K, for 10 Kilobytes.

See the subsection Size suffixes for a list of valid suffixes.

Archive format selection

-H, --format=FORMAT

Create archive of the given format.

Valid formats are:

gnu
GNU tar 1.13.x format
oldgnu
GNU format as per tar <= 1.12.
pax, posix
POSIX 1003.1-2001 (pax) format.
ustar
POSIX 1003.1-1988 (ustar) format.
v7
Old V7 tar format.
--old-archive, --portability
Same as --format=v7.
--pax-option=keyword[[:]=value][,keyword[[:]=value]]...

Control pax keywords when creating PAX archives (-H pax).

This option is equivalent to the -o option of the pax(1) utility.

--posix
Same as --format=posix.
-V, --label=TEXT

Create archive with volume name TEXT.

If listing or extracting, use TEXT as a globbing pattern for volume name.

Compression options

-a, --auto-compress
Use archive suffix to determine the compression program.
-I, --use-compress-program=COMMAND

Filter data through COMMAND. It must accept the -d option, for decompression.

The argument can contain command line options.

-j, --bzip2
Filter the archive through bzip2(1).
-J, --xz
Filter the archive through xz(1).
--lzip
Filter the archive through lzip(1).
--lzma
Filter the archive through lzma(1).
--lzop
Filter the archive through lzop(1).
--no-auto-compress
Do not use archive suffix to determine the compression program.
-z, --gzip, --gunzip, --ungzip
Filter the archive through gzip(1).
-Z, --compress, --uncompress
Filter the archive through compress(1).
--zstd
Filter the archive through zstd(1).

Local file selection

--add-file=FILE
Add FILE to the archive (useful if its name starts with a dash).
--backup[=CONTROL]

Backup before removal. The CONTROL argument, if supplied, controls the backup policy. Valid values are:

none, off
Never make backups.
t, numbered
Make numbered backups.
nil, existing
Make numbered backups if numbered backups exist, simple backups otherwise.
never, simple
Always make simple backups.

If CONTROL is not given, the value is taken from the VERSION_CONTROL environment variable. If it is not set, existing is assumed.

-C, --directory=DIR
Change to DIR before performing any operations. This option is order-sensitive, i.e. it affects all options that follow.
--exclude=PATTERN
Exclude files matching PATTERN, a glob(3)-style wildcard pattern.
--exclude-backups
Exclude backup and lock files.
--exclude-caches
Exclude contents of directories containing file CACHEDIR.TAG, except for the tag file itself.
--exclude-caches-all
Exclude directories containing file CACHEDIR.TAG and the file itself.
--exclude-caches-under
Exclude everything under directories containing CACHEDIR.TAG.
--exclude-ignore=FILE
Before dumping a directory, see if it contains FILE. If so, read exclusion patterns from this file. The patterns affect only the directory itself.
--exclude-ignore-recursive=FILE
Same as --exclude-ignore, except patterns affect both the directory and all its subdirectories.
--exclude-tag=FILE
Exclude contents of directories containing FILE, except for FILE itself.
--exclude-tag-all=FILE
Exclude directories containing FILE.
--exclude-tag-under=FILE
Exclude everything under directories containing FILE.
--exclude-vcs
Exclude version control system directories.
--exclude-vcs-ignores
Exclude files matching patterns from VCS ignore files (.cvsignore, .gitignore, .bzrignore, .hgignore).
-h, --dereference
Follow symlinks; archive and dump the files they point to.
--hard-dereference
Follow hard links; archive and dump the files they refer to.
-K, --starting-file=MEMBER
Begin at the given member in the archive.
--newer-mtime=DATE
Work on files whose data changed after DATE. If DATE starts with / or ., it is taken as a file name and its mtime is used.
--no-null
Disable the effect of the previous --null option.
--no-recursion
Avoid descending automatically in directories.
--no-unquote
Do not unquote input file or member names.
--no-verbatim-files-from
Treat file list entries as command-line arguments (default behavior).
--null
Read null-terminated names from -T options; disables special handling of names starting with -.
-N, --newer=DATE, --after-date=DATE
Only store files newer than DATE. If it starts with / or ., it is treated as a file name and its mtime is used.
--one-file-system
Stay in local file system when creating archive.
-P, --absolute-names
Do not strip leading slashes from file names.
--recursion
Recurse into directories (default).
--suffix=STRING
Backup before removal, override default suffix.
-T, --files-from=FILE
Read file names to extract or create from FILE. Names are normally LF-separated unless --null is used.
--unquote
Unquote file or member names (default).
--verbatim-files-from
Treat each line from file list as a literal file name.
-X, --exclude-from=FILE
Exclude files matching patterns listed in FILE.

File name transformations

--strip-components=NUMBER
Strip NUMBER leading components from file names on extraction.
--transform=EXPRESSION, --xform=EXPRESSION
Use sed replace EXPRESSION to transform file names.

File name transformations

--strip-components=NUMBER
Strip NUMBER leading components from file names on extraction.
--transform=EXPRESSION, --xform=EXPRESSION
Use sed replace EXPRESSION to transform file names.

File name matching options

These options affect both exclude and include patterns.

--anchored
Patterns match file name start.
--ignore-case
Ignore case.
--no-anchored
Patterns match after any / (default for exclusion).
--no-ignore-case
Case sensitive matching (default).
--no-wildcards
Verbatim string matching.
--no-wildcards-match-slash
Wildcards do not match /.
--wildcards
Use wildcards (default for exclusion).
--wildcards-match-slash
Wildcards match / (default for exclusion).

Informative output

--checkpoint[=N]
Display progress messages every Nth record (default 10).
--checkpoint-action=ACTION
Run ACTION on each checkpoint.
--clamp-mtime
Only set time when the file is more recent than what was given with --mtime.
--full-time
Print file time to its full resolution.
--index-file=FILE
Send verbose output to FILE.
-l, --check-links
Print a message if not all links are dumped.
--no-quote-chars=STRING
Disable quoting for characters from STRING.
--quote-chars=STRING
Additionally quote characters from STRING.
--quoting-style=STYLE

Set quoting style for file and member names.

Valid values: literal, shell, shell-always, c, c-maybe, escape, locale, clocale.

-R, --block-number
Show block number within archive with each message.
--show-omitted-dirs
When listing or extracting, list each directory that does not match search criteria.
--show-transformed-names, --show-stored-names
Show file or archive names after transformation by --strip and --transform options.
--totals[=SIGNAL]

Print total bytes after processing the archive.

If SIGNAL is given, print total bytes when this signal is delivered. Allowed signals: SIGHUP, SIGQUIT, SIGINT, SIGUSR1, SIGUSR2. The SIG prefix can be omitted.

--utc
Print file modification times in UTC.
-v, --verbose

Verbosely list files processed.

Each instance increases verbosity level by one (maximum 3).

See GNU Tar Manual, subsection 2.5.1 for details.

--warning=KEYWORD

Enable or disable warning messages identified by KEYWORD. Prefix with no- to disable.

Multiple --warning options accumulate.

General keywords:

  • all — enable all warnings (default)
  • none — disable all warnings
  • filename-with-nuls
  • alone-zero-block

Create-related keywords:

  • cachedir
  • file-shrank
  • xdev
  • file-ignored
  • file-unchanged
  • ignore-archive
  • file-removed
  • file-changed
  • failed-read

Extract-related keywords:

  • existing-file
  • timestamp
  • contiguous-cast
  • symlink-cast
  • unknown-cast
  • ignore-newer
  • unknown-keyword
  • decompress-program
  • record-size

Incremental extraction keywords:

  • rename-directory
  • new-directory
  • xdev
  • bad-dumpdir
-w, --interactive, --confirmation
Ask for confirmation for every action.

Compatibility options

-o
When creating, same as --old-archive. When extracting, same as --no-same-owner.

Size suffixes

Suffix Units Byte Equivalent
b Blocks SIZE × 512
B Kilobytes SIZE × 1024
c Bytes SIZE
G Gigabytes SIZE × 1024³
K Kilobytes SIZE × 1024
k Kilobytes SIZE × 1024
M Megabytes SIZE × 1024²
P Petabytes SIZE × 1024⁵
T Terabytes SIZE × 1024⁴
w Words SIZE × 2

RETURN VALUE

Tar exit code indicates whether it was able to successfully perform the requested operation, and if not, what kind of error occurred.

0
Successful termination.
1
Some files differ.If tar was invoked with the --compare(--diff,-d) command line option, this means that some files in the archive differ from their disk counterparts. If tar was given one of the --create,--append or --update options, this exit code means that some files were changed while being archived and so the resulting archive does not contain the exact copy of the file set.
2
Fatal error. This means that some fatal, unrecoverable error occurred.

If a subprocess that had been invoked by tar exited with a nonzero exit code, tar itself exits with that code as well. This can happen, for example, if a compression option (e.g. -z) was used and the external compressor program failed. Another example is rmt failure during backup to a remote device.

EXAMPLES

        tar -cf archive.tar file1 file2
        tar -xf archive.tar
        tar -tf archive.tar
        tar -czf archive.tar.gz dir/
      

SEE ALSO

  • bzip2(1)
  • compress(1)
  • gzip(1)
  • lzma(1)
  • lzop(1)
  • rmt(8)
  • symlink(7)
  • xz(1)
  • zstd(1)

Complete tar manual: run info tar or use emacs(1) info mode to read it.

Online copies of GNU tar documentation in various formats can be found at:

    http://www.gnu.org/software/tar/manual
  

BUG REPORTS

Report bugs to <bug-tar@gnu.org>.

COPYRIGHT

Copyright © 2013-2019 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.