tar reads and writes headers in either the original TAR format from UNIX systems or the USTAR format defined by the POSIX 1003.1 standard.
The pax command reads and writes headers in any of the tar formats.
The tar command supports both the older UNIX-compatible tar formats and the extended USTAR format. The –X option needs to be used to enable extended USTAR format. The extended USTAR format allows more information to be stored and supports longer pathnames. There is also a non-portable OS390 format (–S option) which also allows storing of additional file attributes and longer pathnames.
A tar archive, in either format, consists of one or more blocks, which are used to represent member files. Each block is 512 bytes long; you can use the –b option with tar to indicate how many of these blocks are read or written (or both) at once.
Each member file consists of a header block, followed by zero or more blocks containing the file contents. The end of the archive is indicated by two blocks filled with binary zeros. Unused space in the header is left as binary zeros.
The header information in a block is stored in a printable ASCII form, so that tar archives are easily ported to different environments. If the contents of the files on the archive are all ASCII, the entire archive is ASCII.
Field width | Field Name | Meaning |
---|---|---|
100 | name | Name of file |
8 | mode | File mode |
8 | uid | Owner user ID |
8 | gid | Owner group ID |
12 | size | Length of file in bytes |
12 | mtime | Modify time of file |
8 | chksum | Checksum for header |
1 | link | Indicator for links |
100 | linkname | Name of linked file |
tar determines that the USTAR format is being used by the presence of the null-terminated string USTAR in the magic field. All fields before the magic field correspond to those of the UNIX format, except that typeflag replaces the link field.
Field width | Field name | Meaning |
---|---|---|
100 | name | Name of file |
8 | mode | File mode |
8 | uid | Owner user ID |
8 | gid | Owner group ID |
12 | size | Length of file in bytes |
12 | mtime | Modify time of file |
8 | chksum | Checksum for header |
1 | typeflag | Type of file |
100 | linkname | Name of linked file |
6 | magic | USTAR indicator |
2 | version | USTAR version |
32 | uname | Owner user name |
32 | gname | Owner group name |
8 | devmajor | Device major number |
8 | devminor | Device minor number |
155 | prefix | Prefix for file name |
Compressed tar archives are equivalent to the corresponding archive being passed to a 14-bit compress command.
The cpio and tar commands