Scroll to navigation

TAR(1) General Commands Manual TAR(1)

NAME

tar
The GNU version of the tar archiving utility

SYNOPSIS

tar [
-
] A --catenate --concatenate | c --create | d --diff --compare | --delete | r --append | t --list | --test-label | u --update | x --extract --get [
options
] [
pathname ...
]

DESCRIPTION

Tar stores and extracts files from a tape or disk archive.
The first argument to tar should be a function; either one of the letters Acdrtux, or one of the long function names. A function letter need not be prefixed with ``-'', and may be combined with other single-letter options. A long function name must be prefixed with --. Some options take a parameter; with the single-letter form these must be given as separate arguments. With the long form, they may be given by appending =value to the option.

FUNCTION LETTERS

Main operation mode:
, --catenate, --concatenate
append tar files to an archive
, --create
create a new archive
, --diff, --compare
find differences between archive and file system
delete from the archive (not on mag tapes!)
, --append
append files to the end of an archive
, --list
list the contents of an archive
test the archive volume label and exit
, --update
only append files newer than copy in archive
, --extract, --get
extract files from an archive

OTHER OPTIONS

Operation modifiers:
-[0-7][lmh]
specify drive and density
, --auto-compress
use archive suffix to determine the compression program
Enable the POSIX ACLs support
Disable the POSIX ACLs support
=FILE
add given FILE to the archive (useful if its name starts with a dash)
patterns match file name start
patterns match after any '/' (default for exclusion)
preserve access times on dumped files, either by restoring the times after reading (METHOD='replace'; default) or by not setting the times in the first place (METHOD='system')
do not use archive suffix to determine the compression program
, --blocking-factor BLOCKS
BLOCKS x 512 bytes per record
, --read-full-records
reblock as we read (for 4.2BSD pipes)
backup before removal, choose version CONTROL
, --directory DIR
change to directory DIR
check device numbers when creating incremental archives (default)
do not check device numbers when creating incremental archives
display progress messages every NUMBERth record (default 10)
=ACTION
execute ACTION on each checkpoint
delay setting modification times and permissions of extracted directories until the end of extraction
cancel the effect of --delay-directory-restore option
=PATTERN
exclude files, given as a PATTERN
exclude backup and lock files
exclude contents of directories containing CACHEDIR.TAG, except for the tag file itself
exclude directories containing CACHEDIR.TAG
exclude everything under directories containing CACHEDIR.TAG
=FILE
exclude contents of directories containing FILE, except for FILE itself
=FILE
exclude directories containing FILE
=FILE
exclude everything under directories containing FILE
exclude version control system directories
, --file ARCHIVE
use archive file or device ARCHIVE
, --info-script, --new-volume-script NAME
run script at end of each tape (implies -M)
archive file is local even if it has a colon
print file time to its full resolution
, --listed-incremental FILE
handle new GNU-format incremental backup
, --incremental
handle old GNU-format incremental backup
=NAME
force NAME as group for added files
, --dereference
follow symlinks; archive and dump the files they point to
, --format FORMAT
create archive of the given formatFORMAT is one of the following:
GNU tar 1.13.x format
GNU format as per tar <= 1.12
POSIX 1003.1-2001 (pax) format
same as pax
POSIX 1003.1-1988 (ustar) format
old V7 tar format
follow hard links; archive and dump the files they refer to
, --ignore-zeros
ignore zeroed blocks in archive (means EOF)
, --use-compress-program PROG
filter through PROG (must accept -d)
ignore case
case sensitive matching (default)
ignore exit codes of children
treat non-zero exit codes of children as error
do not exit with nonzero on unreadable files
=FILE
send verbose output to FILE
, --bzip2
, --xz
, --keep-old-files
don't replace existing files when extracting, treat them as errors
, --starting-file MEMBER-NAME
begin at member MEMBER-NAME when reading the archive
preserve existing symlinks to directories when extracting
don't replace existing files that are newer than their archive copies
, --check-links
print a message if not all links are dumped
, --tape-length NUMBER
change tape after writing NUMBER x 1024 bytes
=NUMBER
dump level for created listed-incremental archive
, --touch
don't extract file modified time
, --multi-volume
create/list/extract multi-volume archive
=CHANGES
force (symbolic) mode CHANGES for added files
=DATE-OR-FILE
set mtime for added files from DATE-OR-FILE
, --seek
archive is seekable
, --newer, --after-date DATE-OR-FILE
only store files newer than DATE-OR-FILE
=DATE
compare date and time when data changed only
-T reads null-terminated names, disable -C
disable the effect of the previous --null option
always use numbers for user/group names
, --to-stdout
extract files to standard output
process only the NUMBERth occurrence of each file in the archive; this option is valid only in conjunction with one of the subcommands --delete, --diff, --extract or --list and when a list of files is given either on the command line or via the -T option; NUMBER defaults to 1
, --portability
same as --format=v7
stay in local file system when creating archive
overwrite existing files when extracting
overwrite metadata of existing directories when extracting (default)
preserve metadata of existing directories
=NAME
force NAME as owner for added files
, --preserve-permissions, --same-permissions
extract information about file permissions (default for superuser)
, --absolute-names
don't strip leading '/'s from file names
=keyword[[:]=value][,keyword[[:]=value]]...
control pax keywords
same as --format=posix
same as both -p and -s
=STRING
additionally quote characters from STRING
=STRING
disable quoting for characters from STRING
=STYLE
set name quoting style; see below for valid STYLE values
, --block-number
show block number within archive with each message
=NUMBER
NUMBER of bytes per record, multiple of 512
recurse into directories (default)
avoid descending automatically in directories
empty hierarchies prior to extracting directory
remove files after adding them to the archive
disable use of some potentially harmful options
=COMMAND
use given rmt COMMAND instead of rmt
=COMMAND
use remote COMMAND instead of rsh
, --preserve-order, --same-order
member arguments are listed in the same order as the files in the archive
, --sparse
handle sparse files efficiently
try extracting files with the same ownership as exists in the archive (default for superuser)
extract files as yourself (default for ordinary users)
apply the user's umask when extracting permissions from the archive (default for ordinary users)
archive is not seekable
Enable the SELinux context support
Disable the SELinux context support
show tar defaults
when listing or extracting, list each directory that does not match search criteria
show valid ranges for snapshot-file fields
, --show-stored-names
show file or archive names after transformation
don't replace existing files when extracting, silently skip over them
=MAJOR[.MINOR]
set version of the sparse format to use (implies --sparse)
=NUMBER
strip NUMBER leading components from file names on extraction
=STRING
backup before removal, override usual suffix ('~' unless overridden by environment variable SIMPLE_BACKUP_SUFFIX)
, --files-from FILE
get names to extract or create from FILE
=COMMAND
pipe extracted files to another program
print total bytes after processing the archive; with an argument - print total bytes when this SIGNAL is delivered; Allowed signals are: SIGHUP, SIGQUIT, SIGINT, SIGUSR1 and SIGUSR2; the names without SIG prefix are also accepted
, --xform EXPRESSION
use sed replace EXPRESSION to transform file names
, --unlink-first
remove each file prior to extracting over it
unquote filenames read with -T (default)
do not unquote filenames read with -T
print file modification times in UTC
, --verbose
verbosely list files processed
, --label TEXT
create archive with volume name TEXT; at list/extract time, use TEXT as a globbing pattern for volume name
=FILE
use/update the volume number in FILE
, --interactive, --confirmation
ask for confirmation for every action
, --verify
attempt to verify the archive after writing it
=KEYWORD
warning control
use wildcards (default for exclusion)
wildcards match '/' (default for exclusion)
wildcards do not match '/'
verbatim string matching
, --exclude-from FILE
exclude patterns listed in FILE
Enable extended attributes support
=MASK
specify the exclude pattern for xattr keys
=MASK
specify the include pattern for xattr keys
Disable extended attributes support
, --gzip, --gunzip --ungzip
, --compress, --uncompress

ENVIRONMENT

The behavior of tar is controlled by the following environment variables, among others:
 
 
Backup prefix to use when extracting, if --suffix is not specified. The backup suffix defaults to `~' if neither is specified.
Options to prepend to those specified on the command line, separated by whitespace. Embedded backslashes may be used to escape whitespace or backslashes within an option.
Device or file to use for the archive if --file is not specified. If this environment variable is unset, use stdin or stdout instead.

EXAMPLES

Create archive.tar from files foo and bar.
tar -cf archive.tar foo bar
List all files in archive.tar verbosely.
tar -tvf archive.tar
Extract all files from archive.tar.
tar -xf archive.tar

SEE ALSO

tar(5), symlink(7), rmt(8)

HISTORY

The tar command appeared in Version 7 AT&T UNIX.

BUGS

The GNU folks, in general, abhor man pages, and create info documents instead. Unfortunately, the info document describing tar is licensed under the GFDL with invariant cover texts, which makes it impossible to include any text from that document in this man page. Most of the text in this document was automatically extracted from the usage text in the source. It may not completely describe all features of the program.
October 31, 2016