Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ tar(1) — OSF/1 SILVER Baselevel 4 rev36

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chdir(2)

umask(2)

tar(4)

tar(1)  —  Commands

OSF  —  Environment_Note_Added

NAME

tar − Manipulates tape archives

SYNOPSIS

tar [-]required_flag[bBfFhilLmpPsSvwn][n | o] [flag_argument ...]
[-e exception] ...  [-C directory] ...  [file ...]

The tar command saves and restores multiple files on a single file (usually a magnetic tape, but it can be any file). 

FLAGS

The function performed by tar is specified by one of the following required flags:

cCreates a new archive; writing begins on the beginning of the tape instead of after the last file.  This command implies r. 

rWrites the named files on the end of the tape.  The c function implies this. 

tThe names of the specified files are listed each time they occur on the tape.  If no file argument is given, all of the names on the tape are listed. 

uAdds the named files to the tape, if the files are not already there or if they were modified since last copied to the tape. 

xExtracts the named files from the tape.  If the named file matches a directory whose contents were written onto the tape, this directory is (recursively) extracted.  The owner, modification time, and mode are restored (if possible).  If no file argument is given, the entire content of the tape is extracted.  Note that if multiple entries specifying the same file are on the tape, the last one overwrites all earlier ones. 

The following flags can be used with the required flag:

bThe tar command uses the next argument as the blocking factor for tape records. The default is 20 (larger values can be specified at the risk of creating a tape archive that some systems’ tape drives might not be able to restore).  Use this flag only with raw magnetic tape archives. The block size is determined automatically when reading tapes (key letters x and t). 

BForces input and output blocking to the blocking factor (see the b flag).  This flag exists so that tar can work across a communications channel where the blocking cannot be maintained. 

fThe tar command uses the next argument as the name of the archive instead of /dev/rmtn. If the name of the file is − (dash), tar writes to standard output or reads from standard input, whichever is appropriate.  Thus, tar can be used as the head or tail of a filter chain.  tar can also be used to move hierarchies with the command:

cd fromdir; tar cf - . | (cd todir; tar xf -)

FChecks certain filenames before archiving.  Source Code Control System (SCCS), Revision Control System (RCS), files named core, errs, a.out, and files ending in .o are not archived. 

hForces tar to follow symbolic links as if they were normal files or directories.  Normally, tar does not follow symbolic links, but instead saves the link text in the archive. 

iIgnores checksum errors.  The tar command writes a file header containing a checksum for each file in the archive.  When this flag is not specified, the system verifies the contents of the header blocks by recomputing the checksum and stops with a directory checksum error when a mismatch occurs.  When this flag is specified, tar logs the error and then scans forward until it finds a valid header block.  This permits restoring files from later volumes of a multivolume archive without reading earlier volumes. 

lTells tar to complain if it cannot resolve all of the links to the files dumped.  If this is not specified, no error messages are printed. 

LTries to create a symbolic link if tar is unsuccessful in its attempt to link (hard link) two files. 

mTells tar not to restore the modification times.  The modification time will be the time of extraction.  This is always the case with symbolic links. 

nAllows tar headers to be created with filenames that cannot be null-terminated if they are exactly the maximum length (as specified in POSIX).  This flag is mutually exclusive with the o flag (that is, new vs. old).  When specified, each of these flags turns off the other; neither flag is turned on by default, however. 

oThe o flag is provided for backward compatibility.  Specify this flag if the archive will be restored on a system with an older version of tar.  On output, tar normally places information specifying owner and modes of directories in the archive.  Former versions of tar, when encountering this information will give an error message of the form

name/: cannot create.

This modifier suppresses the directory information.  It also prevents archiving special files and FIFOs that earlier versions of tar would not be able to extract properly.  (Note that although anyone can archive special files, only a user who has superuser authority can extract them from the archives.) 

When o is used for reading, it causes the extracted file to take on the user and group ID (uid and gid) of the user running the program, rather than those of the tape.  This is the default for the ordinary user. 

This flag is mutually exclusive with the n flag (that is, new vs. old).  When specified, each of these flags turns off the other; neither flag is turned on by default, however. 

pRestores files to their original modes, ignoring the present umask.  Set-user-ID and sticky information will also be restored if the user is superuser. 

PSpecifies the prefix that is to be stripped off of the filenames archived to or extracted from tape.  See also the s flag. 

sTells tar to strip off any leading slashes from pathnames during extraction.  This is useful when restoring a tape that was created on a system with a different file system structure.  (See also the P flag.) 

S blocksb | feet[@density]
Specifies the number of 512-byte blocks per volume (first form), independent of the tape blocking factor.  You can also specify the size of the tape in feet, and optionally density, by using the second form. Feet are assumed to be 11 inches long to be conservative.  This flag lets you deal more easily with multivolume tape archives, where tar must be able to determine how many blocks fit on each volume. 

Note that tape drives vary in density capabilities.  The density argument is used in the amount of data that tar can fit on a tape. 

vNormally tar does its work silently.  The v (verbose) option makes tar print the name of each file it treats preceded by the function letter.  With the t function, the verbose option gives more information about the tape entries than just their names. 

wCauses tar to print the action to be taken followed by the name of the file, and then to wait for the user’s confirmation. If a word beginning with y, or the locale’s equivalent of a y, is given, the action is performed.  If any other input is given, the action is not performed. 

nSelects an alternate drive on which the tape is mounted by specifying a digit.  The default is drive 0 (zero) at 1600 bpi, which is normally /dev/rmt8. 

-eAdds the following argument to a list of exception strings that prevent files whose names match exactly from being archived. 

-CIf a filename is preceded by −C, tar performs a chdir() to that filename.  This allows multiple directories not related by a close common parent to be archived using short relative pathnames.  For example, to archive files from /usr/include and from /etc, one might use the following command line:

tar c -C /usr/include -C /etc

Therefore, if you do not specify an absolute filename, the filename is considered relative to the previous -C directory.  When you specify this flag multiple times on the command line, make sure to specify subsequent -C directories relative to the preceding -C directories. 

If an error occurs while trying to change to the requested directory, subsequent filenames on the command line that are not absolute (that is, have no leading / (slash)) are skipped until the next -C flag is specified. 

Only the -e and -C flags must be preceded by a - (dash) and can be specified more than once on a single command line or interspersed within the list of filenames.  All other flags must be specified together (with no separating spaces) before -e, -C, and the file list.  For all flags that require arguments, the arguments must follow the string of flags and be ordered in the same way as the specified flags. 

Previous restrictions on the tar command’s ability to properly handle blocked archives have been lifted. 

DESCRIPTION

The tar command is used to save and restore data from traditional format tar archives. 

The actions of the tar command are controlled by a string containing, at most, one required flag and possibly one or more optional flags.  Other arguments to tar are file or directory names specifying which files to dump or restore.  In all cases, appearance of a directory name refers to the files and (recursively) subdirectories of that directory. 

The LC_MESSAGES variable determines the locale’s equivalent of y or n (for yes/no queries). 

NOTES

     1.There is no way to ask for the nth occurrence of a file. 

     2.Tape errors are handled ungracefully. 

     3.The u option can be slow. 

     4.The current limit on filename length is 256 bytes.  The current limit on file links (hard or soft) is 100 bytes. 

     5.There is no way selectively to follow symbolic links. 

     6.When extracting tapes created with the r or u options, directory modification times might not be set correctly. 

EXAMPLES

To create a tar archive to device /dev/rmt12, enter:

tar cvfb /dev/rmt12 20 -e ./foo -C /usr/glenn -e ./bar
-e ./logs/logfile -C /usr/gaston

(Enter the command entirely on one line, not on two lines as shown above.) 

The preceding command line specifies a blocking factor of 20.  The resulting archive contains all files and directories in /usr/glenn except for file ./foo and all files and directories in /usr/gaston except for ./foo and ./bar and ./logs/logfile. 

FILES

/dev/rmtnDevice name used with the n flag. 

/tmp/tar∗Temporary file used with the u function. 

ENVIRONMENT NOTES

This section describes system features that are not generic to OSF/1 but that are provided in this OSF/1 implementation. 

Digital Extensions

REach named file contains a list of file names separated by newlines.  This list is added to (c function key) or extracted from (x function key) the archive. 

RELATED INFORMATION

Functions:  chdir(2), umask(2). 

Files:  tar(4). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026