Content-type: text/html Man page of tar


Section: Devices and Network Interfaces (4)
Index Return to Main Contents


tar, pax - Archive file format  


The cpio, pax, and tar commands dump several files into one, in a medium suitable for transportation. This file is often referred to as a tar file, or tar tape, since it was originally designed to be on an archive tape.

An archive file is a series of blocks, with each block of size TBLOCK. A file on the archive is represented by a header block which describes the file, followed by zero or more blocks which give the contents of the file. At the end of the tape are two blocks filled with binary zeros, as an end-of-file indicator.

The blocks are grouped for physical I/O operations. Each group of n blocks (where n is set by the b keyletter on the tar command line, with a default of 20 blocks) is written with a single system call. On nine-track tapes, the result of this write is a single tape record. The last group is always written at the full size, so blocks after the two zero blocks contain random data. On reading, the specified or default group size is used for the first read, but if that read returns less than a full tape block, the reduced block size is used for further reads.

The header block looks like:

Field NameOffsetLength

name  0100    

The name field is the name of the file, as specified on the command line. Files dumped because they were in a directory that was named on the command line have the directory name as prefix and /filename as suffix.

The mode field is the file mode, with the top bit masked off.

The uid and gid fields are the user id and group id numbers that own the file.

The size field is the size of the file in bytes. Links and symbolic links are dumped with this field specified as zero.

The mtime field is the modification time of the file at the time it was dumped.

The chksum field is an octal ASCII value which represents the sum of all the bytes in the header block. When calculating the checksum, the chksum field is treated as if it were all blanks.

The typeflag field identifies the type of data following the header. Valid values are: A Global Extended Header follows. An Extended Header follows. Archive data follows.

The Global Extended Header and Extended Header formats are only produced when the tar command is used with the -E option, or the pax command is used with the -x xtar option.

The linkname field is the name of the file that this file is linked to, if any. If this field is empty, the file is not linked.

The first time a given i-node number is dumped, it is dumped as a regular file. Subsequently, it is dumped as a link instead. Upon retrieval, if a link entry is retrieved but the file it was linked to is not, an error message is printed and the tape must be rescanned manually to retrieve the file that it is linked to.

The magic field is the magic number for the file type as described in the magic(4) reference page.

The version field is always 00 (zero-zero).

The uname and gname fields are the user name and group names that own the file.

The devmajor and devminor fields are the device major and minor numbers as described in the mknod(8) reference page.

The name, linkname, and prefix fields are null-terminated strings, except when all characters in the field are non-null characters. The typeflag field is a single character. The other fields are zero-filled octal numbers in ASCII format terminated by a null character.

Unused fields of the header are binary zeros (and are included in the checksum).  


The encoding of the header is designed to be portable across platforms. If filenames are chosen that use characters not in the portable filename character set, results are unpredictable.  


The layout of an archive with a Global Extended Header, two data files, and the end of archive is shown here.

ustar Header (typeflag=g)
Global Extended Header Data

ustar Header (typeflag=x)
Extended Header Data
ustar Header (typeflag=0)
Data for File 1

ustar Header (typeflag=0)
Data for File 2

ustar Header (typeflag=0)
Data for File n

Block of binary zeroes

Block of binary zeroes



Commands: cpio(1), mknod(8), pax(1), tar(1)

Files: magic(4) delim off




This document was created by man2html, using the manual pages.
Time: 02:40:05 GMT, October 02, 2010