TAR(1) | GNU TAR Manual | TAR(1) |
tar - an archiving utility
tar {A|c|d|r|t|u|x}[GnSkUWOmpsMBiajJzZhPlRvwo] [ARG...]
tar -A [OPTIONS] ARCHIVE ARCHIVE
tar -c [-f ARCHIVE] [OPTIONS] [FILE...]
tar -d [-f ARCHIVE] [OPTIONS] [FILE...]
tar -t [-f ARCHIVE] [OPTIONS] [MEMBER...]
tar -r [-f ARCHIVE] [OPTIONS] [FILE...]
tar -u [-f ARCHIVE] [OPTIONS] [FILE...]
tar -x [-f ARCHIVE] [OPTIONS] [MEMBER...]
tar {--catenate|--concatenate} [OPTIONS] ARCHIVE ARCHIVE
tar --create [--file ARCHIVE] [OPTIONS] [FILE...]
tar {--diff|--compare} [--file ARCHIVE] [OPTIONS] [FILE...]
tar --delete [--file ARCHIVE] [OPTIONS] [MEMBER...]
tar --append [-f ARCHIVE] [OPTIONS] [FILE...]
tar --list [-f ARCHIVE] [OPTIONS] [MEMBER...]
tar --test-label [--file ARCHIVE] [OPTIONS] [LABEL...]
tar --update [--file ARCHIVE] [OPTIONS] [FILE...]
tar --update [-f ARCHIVE] [OPTIONS] [FILE...]
tar {--extract|--get} [-f ARCHIVE] [OPTIONS] [MEMBER...]
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
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
If any discrepancies occur between this manpage and the GNU Tar Manual, the later shall be considered the authoritative source.
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.
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 arguments 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 has 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 the verbose operation, and the f option takes an argument that sets the name of the archive to operate upon. The following command, written in the traditional style, instructs tar to store all files from the directory /etc into the archive file etc.tar verbosely listing the files being archived:
tar cfv a.tar /etc
In UNIX or short-option style, each option letter is prefixed with a single dash, as in other command line utilities. If an option takes argument, the argument follows it, either as a separate command line word, or immediately following the option. However, if the option takes an optional argument, the argument 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 the short-option style could look like:
tar -cvf a.tar /etc or tar -c -v -f a.tar /etc
In GNU or long-option style, each option begins with two dashes and has a meaningful name, consisting of lower-case letters and dashes. When used, the long option can be abbreviated to its initial letters, provided that this does not create ambiguity. Arguments to long options are supplied either as a separate command line word, immediately following the option, 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 a.tar --verbose /etcor (abbreviating some options):
tar --cre --file=a.tar --verb /etc
The options in all three styles can be intermixed, although doing so with old options is not encouraged.
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.
Compressed archives cannot be concatenated.
This option does not operate on compressed archives. There is no short option equivalent.
There is no short option equivalent for this option.
When listing or extracting, the actual contents of FILE is not inspected, it is needed only due to syntactical requirements. It is therefore common practice to use /dev/null in its place.
These options control tar actions when extracting a file over an existing copy on disk.
f Regular file d Directory l Symbolic link h Hard link b Block device c Character device
Currently only regular files are supported.
Additionally, the following variables contain information about tar operation mode and the archive being processed:
When used with --group-map=FILE, affects only those files whose owner group is not listed in FILE.
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.
When used with --owner-map=FILE, affects only those files whose owner is not listed in FILE.
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.
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.
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 a @ 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.
If the info script fails, tar exits; otherwise, it begins writing the next volume.
This option implies -M.
If CONTROL is not given, the value is taken from the VERSION_CONTROL environment variable. If it is not set, existing is assumed.
This is the default behavior. The --no-verbatim-files-from option is provided as a way to restore it after --verbatim-files-from option.
This option is positional: it affects all --files-from options that occur after it in, until --verbatim-files-from option or end of line, whichever occurs first.
It is implied by the --no-null option.
See also --verbatim-files-from.
Unless specified otherwise, the FILE must contain a list of names separated by ASCII LF (i.e. one name per line). The names read are handled the same way as command line arguments. They undergo quote removal and word splitting, and any string that starts with a - is handled as tar command line option.
If this behavior is undesirable, it can be turned off using the --verbatim-files-from option.
The --null option instructs tar that the names in FILE are separated by ASCII NUL character, instead of LF. It is useful if the list is generated by find(1) -print0 predicate.
This option affects all --files-from options that occur after it in the command line. Its effect is reverted by the --no-verbatim-files-from} option.
This option is implied by the --null option.
See also --add-file.
These options affect both exclude and include patterns.
Multiple --warning messages accumulate.
Keywords controlling general tar operation:
Keywords applicable for tar --create:
Keywords applicable for tar --extract:
$ tar --warning=decompress-program -x -f archive.Z tar (child): cannot run compress: No such file or directory tar (child): trying gzip
This means that tar first tried to decompress archive.Z using compress, and, when that failed, switched to gzip.
Keywords controlling incremental extraction:
Suffix Units Byte Equivalent b Blocks SIZE x 512 B Kilobytes SIZE x 1024 c Bytes SIZE G Gigabytes SIZE x 1024^3 K Kilobytes SIZE x 1024 k Kilobytes SIZE x 1024 M Megabytes SIZE x 1024^2 P Petabytes SIZE x 1024^5 T Terabytes SIZE x 1024^4 w Words SIZE x 2
Tar exit code indicates whether it was able to successfully perform the requested operation, and if not, what kind of 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.
bzip2(1), compress(1), gzip(1), lzma(1), lzop(1), rmt(8), symlink(7), xz(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
Report bugs to <bug-tar@gnu.org>.
Copyright © 2013 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.
November 16, 2017 | TAR |