|Previous||Table of Contents||Next|
The external tar command is a tape archive program. It is used to archive files from disk to tape. The media does not have to be tape. You can create a tar file on disk, diskette, cartridge tape, or 9-track tape. You also use tar to retrieve archived files from a tar file.
Following is the general format of the tar command.
tar -c[bfLvw[ds]] block device filelist tar -r[bLvw[ds]] block device [ filelist ] tar -t[fLv>[ds]] device tar -u[bLvw[ds]] block device [ filelist ] tar -x[flLmovw[ds]] device [ filelist ]
tar -c[Bbfhvw[d]] block device filelist -C alt_files tar -r[Bbhvw[d]] block device [ filelist ] -C alt_files tar -t[fv[d]] device tar -u[Bbhvw[d]] block device [ filelist ] -C alt_files tar -x[Bflmopvw[d]] device [ filelist ]
Some BSD systems do not support the hyphen (-) preceding the options. Thus it must be left off the command line for tar to work properly.
The following list describes the options and their arguments that may be used to control how tar functions. There are two types of options used with tar. There are options that control how tar functions and options that modify how each function performs.
FUNCTION TYPE OPTIONS
These options specify what function tar is to perform.
|-c||Creates a new archive file. The writing starts at the beginning of the archive. The -r option is automatically assumed.|
|-r||Replaces the named files. The files are written on the end of the tar file.|
|-t||Displays a table of contents of all files contained in the tar file.|
|-u||Updates the archive file. Adds the files to the tar file if they are not already archived and if they have been modified since the last archive was written.|
|-x||Extracts files from the tar file. If no files are listed, all files are extracted from the tar file. If multiple versions of a file exist in the tar file, only the last (latest) version is extracted. If the named file is a directory, then the entire directory tree is extracted. If a file no longer exists on disk, the file is created with the modes from the archived version of the file. The set-UID and set-GID bits are not set on extracted files unless you are super-user.|
MODIFIER TYPE OPTIONS
These options modify how tar performs the specified function.
|-b||Causes tar to set the blocking factor to the size specified in the block argument. The value of block can be from 1 to 64. The default is 1. This modifier should only be used when you wish to extract files from or write files to a raw character special archive. The block size is automatically determined when extracting files from a block special device.|
|-f||Causes tar to use the device argument as the output device where the tar file is written. If the device is - (hyphen) tar writes to the standard output or reads from the standard input, depending on the function options specified. This allows you to use tar in a pipeline command.|
|ds||This option determines which tape drive (d) and what speed (s) to use for the archive. This notation is used on larger systems where multiple tape drives exist. A typical set of devices might be /dev/mt/0m through /dev/mt/5m. The d option specifies 0 through 5. The m describes medium speed(1600 BPI). Tape drives may be any media device. The default device is 0m (/dev/mt/0m).|
|-l||Causes tar to display messages for all links it cannot resolve during archival of files. If -l is not used, no error messages are displayed. This option is only useful with the -c, -r, and -u options.|
|-L||Causes symbolic links to be followed.|
|-m||Causes tar not to restore modification times to the time held before archival. Instead, the modification time of each file is set to the time the file is extracted.|
|-o||Causes tar to set the user ID and group ID to your IDs instead of the IDs saved on tape. This option is only useful with the -x option.|
|-v||Causes tar to be verbose. It displays the function and filename for each file being archived or extracted.|
|-w||Causes tar to perform the verbose option and after each function and filename is displayed, it waits for you to confirm whether to perform the function or not. If you start a string with y, the function is performed, otherwise the filename is skipped in the process.|
|-B||Forces input and output blocking to 20 blocks per record.|
|-b||Same as System V, except the default blocking factor is 20. The default blocking factors varies from system to system and depends on the device being written to by tar.|
|-C||Change directory to the following directory argument.|
|-h||Forces tar to treat symbolic links as normal files or directories. Normally symbolic links are not followed.|
|-p||Restores files to their present mode. Your current umask is ignored. If you are the super-user, the set-uid and sticky bit information are also extracted. Only usable with the -x option.|
|0-9||Specifies the device used to access the tape drive. The base of the device name may vary among systems. Common defaults are /dev/rmt[0-9], /dev/rst[0-9], /dev/rct[0-9]. The number may be two digits.|
|Previous||Table of Contents||Next|