tar — tape file archiver
command saves and restores archives of files on a magnetic tape,
a flexible disk, or a regular file.
The default archive file is
If the legacy DSF is disabled, the default value is
Its actions are controlled by the
is a string of characters containing exactly one function letter
and zero or more function modifiers,
specified in any order.
Whitespace is not permitted in
string can be preceded by a hyphen
as when specifying options in other HP-UX commands, but it is not necessary.
- arg ...
function modifiers each require an
argument (see below).
are specified, the order of the
arguments must match the order of the modifiers.
If specified, the
arguments must be separated from the key and each other by whitespace.
specifies a file being saved or restored.
is a directory name,
it refers to the files and (recursively)
the subdirectories contained in that directory.
- -C directory
to perform a
arguments are relative to
This allows multiple directories
not related by a close or common parent
to be archived using short relative path names.
The value of
is stored in the archive.
The value of
is not stored.
The function portion of the
is specified by exactly one of the following letters:
Create a new archive.
Write from the beginning of the archive
instead of appending after the last file.
Any previous information in the archive is overwritten.
Add the named
to the end of the archive. The same blocking factor used to create the
archive must be used to append to it. This option cannot be used if the
archive is a tape.
List the names of all the files in the archive.
function modifier expands this listing
to include the file modes and owner numbers.
The names of all files are listed each time they occur on the tape.
Add any named
to the archive if it is not already present or has been modified
since it was last written in the archive. The same blocking factor used to
create the archive must be used to update it.
Extract the named
from the archive and restore it to the system.
If a named
matches a directory whose contents were written to the archive,
this directory is (recursively) extracted.
If a named
on tape does not exist on the system, the
is created as follows:
The user, group, and other protections are restored from the tape.
The modification time is restored from the tape unless the
function modifier is specified.
The file user ID and group ID
are normally those of the restoring process.
The set-user-ID, set-group-ID,
and sticky bits are not set automatically.
function modifiers control the restoration of protection;
see below for more details.
If the files exist, their modes are not changed,
but the set-user-id, set-group-id and sticky bits are cleared.
argument is given, the entire content of the archive is extracted.
Note that if several files with the same name are on the archive,
the last one overwrites all earlier ones.
Function Modifier Keys
The following function modifiers can be used
in addition to the function letters listed above
(note that some modifiers are incompatible with some functions):
Suppress warning messages that
did not archive a file's access control list.
writes a warning message for each file with optional ACL entries.
Use the next
argument as the blocking factor for archive records.
The default is 20;
the maximum is at least 20.
However, if the
modifier is used to specify standard input,
the default blocking factor is 1.
The blocking factor is determined automatically when reading
nine-track tapes (key letters
On nine-track tapes,
the physical tape record length is the same as the block size.
The block size is defined as the logical record size times the blocking factor
(number of logical records per block).
The blocking factor must be specified
when reading flexible disks and cartridge tapes
if they were written with a blocking factor
other than the default.
file is read using a blocking factor not equal to
the one used when the file was written,
an error may occur at the end of the file but there may or
may not be an actual error in the read.
To prevent this problem, a blocking factor of
can be used, although performance may be reduced somewhat.
writes logical records of 512 bytes,
independent of how logical records may be defined elsewhere by other programs
(such as variable-length records (lines) within an ASCII text file).
Fail if the extent attributes are present in the files to be archived.
fails for this reason,
the partially created destination file is not be removed.
Use the next
argument as the name of the archive instead of the default,
If the legacy DSF is disabled the default value is
If the name of the file is
writes to standard output or reads from standard input,
whichever is appropriate, and the default blocking factor becomes 1.
can be used as the head or tail of a pipeline (see EXAMPLES).
to follow symbolic links as if they were normal files or directories.
does not follow symbolic links.
to complain if it cannot resolve all of the links to the files being saved.
is not specified, no error messages are printed.
not to restore the modification time written on the archive.
The modification time of the file will be the time of extraction.
Write a POSIX format archive.
This format allows file names of up to 256 characters in length,
and correctly archives and restores the following file types:
regular files, character and block special devices,
links, symbolic links, directories, and FIFO special files.
It also stores the user and group name of each file
and attempts to use these names to determine
the user-ID and group-ID of a file when restoring it with the
This is the default format.
Suppress writing certain directory information that older versions of
cannot handle on input.
normally writes information specifying owners and modes
of directories in the archive.
Earlier versions of
when encountering this information, give error messages of the form:
is used for reading, it causes the extracted
to take on the user and group IDs
of the user running the program rather than those on the tape.
This is the default for the ordinary user and can be overridden,
to the extent that system protections allow, by using the
Write a pre-POSIX format archive.
to be restored to the original modes and ownerships
written on the archive, if possible.
This is the default for the superuser,
and can be overridden by the
If system protections prevent the ordinary user from executing
the error is ignored, and the ownership is set to that of the
restoring process (see
The set-user-id, set-group-id,
and sticky bit information are restored
as allowed by the protections defined by
operation above succeeds.
Specify a particular nine-track tape drive and density, where
is a tape drive number:
is the density:
= low (800 bpi);
= medium (1600 bpi);
= high (6250 bpi).
This modifier selects the drive
on which the nine-track tape is mounted.
The default is
does its work silently.
(verbose) function modifier causes
to type the name of each file it treats,
preceded by the function letter.
gives more information about the archive entries than just the name.
Same as the
function modifier except that, when using the
also prints out a letter indicating the type of the archived file.
to print the action being taken, followed by the name of the file,
then wait for the user's confirmation.
If the user answers
the action is performed.
Any other input means "no".
When end-of-tape is reached,
prompts the user for a new special file and continues.
If a nine-track tape drive is used as the output device,
it must be configured in Berkeley-compatibility mode (see
O and N
function modifiers specify the format in which
writes the archive. Upon extraction,
can read either format, regardless of the function modifiers used.
determines the format and contents of date and time strings
output when listing the contents of an archive with the
determines the language equivalent of
(for yes/no queries).
is not specified in the environment or is set to the empty string,
the value of
is used as the default.
is not specified or is set to the empty string, it defaults to "C" (see
If any internationalization variable contains an invalid setting,
behaves as if all internationalization variables are set to "C".
International Code Set Support
Single- and multibyte character code sets are supported.
issues self-explanatory messages
about bad key characters, tape read/write errors, and
if not enough memory is available to hold the link tables.
Create a new archive on
onto it, using the default blocking factor of 20.
is made up of one function letter
and two function modifiers
tar cvf /dev/rtape/tape4QIC150 file1 file2
Archive files from
tar cv -C /usr/include . -C /etc .
in a pipeline to copy the entire file system hierarchy under
cd fromdir ; tar cf - . | ( cd todir ; tar xf - )
Archive all files and directories in directory
in the current directory to a file called
also in the current directory:
tar -cvf my_project.TAR my_project
Because of industry standards and interoperability goals,
does not support the archival of files of size 8GB or larger, files that
have user/group ID values of 2097152 (2^21) or greater, or files belonging
to a user/group name of 32 characters or greater.
Files with user/group ID values of 2097152 (2^21) or greater are archived and
restored using the original user/group name of the file.
If the user/group name is not found when restoring the file, then the
user/group ID of the current process is used.
If the user/group name was truncated to fit in the
header, a false match may be made when restoring with this truncated value
if the truncated value is the same as another user/group name on that system.
For more information see
Due to internal limitations in the header structure,
not all file names of fewer than 256 characters fit when using the
If a file name does not fit,
prints a message and does not archive the file.
Link names are still limited to 100 characters when using the
There is no way to ask for the
occurrence of a file.
Tape errors are handled ungracefully.
function key can be slow.
If the archive is a file on disk, flexible disk, or cartridge tape,
and if the blocking factor specified on output is not the default,
the same blocking factor must be specified on input,
because the blocking factor is not explicitly stored in the archive.
Updating or appending to the archive
without following this rule can destroy it.
Some previous versions of
have claimed to support the selective listing of file names using the
function key with a list.
This appears to be an error in the documentation
because the capability does not appear in the original source code.
There is no way to restore an absolute path name to a relative position.
always pads information written to an archive
up to the next multiple of the block size.
Therefore, if you are creating a small archive
and write out one block of information,
reports that one block was written,
but the actual size of the archive might be larger if the
function modifier is used.
is not the same as
Do not create archives on block special devices.
Attempting to do so can causes excessive wear,
leading to premature drive hardware failure.
function keys are not supported on QIC or 8mm devices.
If these options are used with QIC or 8mm devices,
fails and displays the message:
tar: option not supported for this device
was developed by AT&T,
the University of California, Berkeley,
HP, and POSIX.
tar: SVID2, SVID3, XPG2, XPG3