tar(1) — USER COMMANDS
NAME
tar − tape file archiver
SYNOPSIS
/usr/sbin/tar −c[vwfbLkFDhienA#] device block files tapesize incfile . . .
/usr/sbin/tar −c[vwfbLkXDhienA#] device block files tapesize excfile . . .
/usr/sbin/tar −r[vwfbLkFDhienA#] device block files tapesize incfile . . .
/usr/sbin/tar −r[vwfbLkXDhienA#] device block files tapesize excfile . . .
/usr/sbin/tar −t[vfLXien#] device [files . . .] excfile
/usr/sbin/tar −u[vwfbLkXDhienA#] device block files tapesize excfile . . .
/usr/sbin/tar −u[vwfbLkFDhienA#] device block files tapesize incfile . . .
/usr/sbin/tar −x[lmovwfLXpienA#] device [files . . . ] excfile
DESCRIPTION
tar saves and restores files on magnetic tape. Its actions are controlled by a string of characters containing one option (c, r, t, u, or x), and possibly followed by one or more modifiers (v, w, f, b, L, k, F, X, D, h, i, e, n, A, l, m, o, p and #). Other arguments to the command are files (or directory names) specifying which files are to be dumped or restored. In all cases, appearance of a directory name refers to the files and (recursively) subdirectories of that directory.
The options are as follows:
-c Create a new tape; writing begins at the beginning of the tape, instead of after the last file. The -c option implies the -r option.
-r Replace. The named files are written on the end of the tape. The -c and -u options imply the -r option.
-t Table. The names and other information for the specified files are listed each time that they occur on the tape. The listing is similar to the format produced by the ls -l command [see ls(1)]. If no files argument is given, all the names on the tape are listed.
-u Update. The named files are added to the tape if they are not already there, or have been modified since last written on that tape. The -u option implies the -r option.
-x Extract. The named files are extracted from the tape. If a named file matches a directory whose contents had been written onto the tape, this directory is (recursively) extracted. Use the file or directory’s relative path when appropriate, or tar will not find a match. The owner, modification time, and mode are restored (if possible). If no files argument is given, the entire contents of the tape is extracted. Note that if several files with the same name are on the tape, the last one overwrites all earlier ones.
The modifiers below may be used in the order shown in the synopsis.
# This modifier determines the drive on which the tape is mounted (replace # with the drive number) The modifier tells tar to use a drive other than the default drive. The defaults are listed in /etc/default/tar. The following criteria, listed in order of precedence, to determine which device to use.
-f device present on command line
TAPE environment variable set
# option used on command line
the 0 device in /etc/default/tar
v Verbose. Normally, tar does its work silently. The v (verbose) modifier causes it to print the name of each file it treats, preceded by the option. With the -t option, v gives more information about the tape entries than just the name.
w What. This modifier causes tar to print the action to be taken, followed by the name of the file, and then wait for your confirmation. If a word beginning with y is given, the action is performed. Any other input means no. This is not valid with the -t option.
f File. This causes tar to use the device argument as the name of the archive instead of the default. If the name of the file is −, tar writes to the standard output or reads from the standard input, whichever is appropriate. Thus, tar can be used as the head or tail of a pipeline. tar can also be used to move hierarchies with the command:
cd fromdir; tar cf - . | (cd todir; tar xf −)
b Blocking Factor. This modifier causes tar to use the block argument as the blocking factor for tape records. The default is 20. This modifier should not be supplied when operating on regular archives or block special devices. It is mandatory however, when reading archives on raw magnetic tape archives (see f above). The block size is determined automatically when reading tapes created on block special devices (options x and t).
l Link. This modifier causes tar to complain if it cannot resolve all of the links to the files being dumped. If the l modifier is not specified, no error messages are printed.
m Modify. This modifier causes tar to not restore the modification times. The modification time of the file will be the time of extraction.
o Ownership. This modifier causes extracted files to take on the user and group identifier of the user running the program, rather than those on tape. This is only valid with the -x option.
L Follow symbolic links. This modifier causes symbolic links to be followed. By default, symbolic links are not followed.
k This modifier uses the tapesize argument as the size in bytes per volume for non-tape devices (such as a floppy drive). A value of 0 for tapesize causes multi-volume mode to be disabled (interpreted as an infinite volume size). This modifier may be used with the -c, -r, and -u options.
F This modifier uses the incfile argument as a file containing a list of named files (or directories) to be included on the tape. This modifier may only be used with the -c, -r, and -u options. This modifier may not be used with the X modifier.
X This modifier uses the excfile argument as a file containing a list of named files (or directories) to be excluded. This modifier may not be used with the F modifier.
h This modifier causes tar to follow symbolic links as if they were normal files or directories. Normally tar does not follow symbolic links. The h modifier may be used with the -c, -r, and -u options.
p This modifier restores the named file arguments to their original modes, ignoring the present value returned by umask [see umask(2)]. setuid and sticky bit information are also restored if the effective user ID is root. This modifier may only be used with the -x option.
i This modifier causes tar to ignore directory checksum errors.
e This modifier causes tar to quit when certain minor errors are encountered. Otherwise tar will continue when minor errors are encountered.
n This modifier must be used when the device argument is for a non-tape device (for example, a floppy drive).
A This modifier causes absolute pathnames for files to be suppressed, and may be used with the -r, -c, -u, and -x options. This causes all pathnames to be interpreted as relative to the current working directory.
D By default tar uses the industry standard POSIX 1003.1 archive format. The POSIX format for directory entries is not understood by older BSD-derived tar programs. The D option causes directories to be archived in a format which is compatible with these tar programs. This compatible format is achieved by appending a ’/’ character to all directories in the archive. This option should be used with the -r, -c and -u options.
EXAMPLES
Two examples using the TAPE environment variable:
TAPE=/dev/rmt/ctape1n
tar -cf /dev/rmt/ctape1
will use /dev/rmt/ctape1.
TAPE=/dev/rmt/ctape1n
tar -c0h
will use /dev/rmt/ctape1n rather than the 0 entry of /etc/default/tar.
FILES
/etc/default/tar
/tmp/tar∗
/usr/lib/locale/locale/LC_MESSAGES/uxcore
language-specific message file [see LANG on environ(5)]
SEE ALSO
ar(1), cpio(1), ls(1), umask(2)
DIAGNOSTICS
Complains about tape read/write errors.
Complains if insufficient memory is available to hold the link tables.
NOTES
There is no way to ask for the n-th occurrence of a file.
The -b modifier should not be used with archives that are going to be updated. The current magnetic tape driver cannot backspace raw magnetic tape. If the archive is on a disk file, the -b modifier should not be used at all, because updating an archive stored on disk can destroy it.
The current limit on file name length is 100 characters.
When UNIX System V Release 4.0 tar is used on pre-Release 4.0 archives, a false warning message that file permissions have changed will be issued.
If you use tar(1) to extract files from a tape archive, the following warnings will be printed if the user or group of the file being restored do not exist on the system.
tar: problem reading passwd entry
tar: file: owner not changed
tar: problem reading group entry
tar: file: group not changed/f1
The file will be properly extracted, but it will be owned by root and belong to group root instead of the owner and group of the file on the archive.
— Essential Utilities