Main page > File formats > Archives

TAR archive file format

Typical file name extensions
.tar
Magic bytes
None.
However, identification of tar files is not limited to looking at the file extension. Each tar archive entry header also stores a checksum on itself. Thus, reading the first 512 bytes of a potential tar file, creating that checksum and comparing it to the stored checksum will tell if the file really is in tar format.
MIME types
application/x-tar
File structure
A tar archive interchangeably stores headers and file data.
Headers are 512 bytes large, followed by zero or more blocks of 512 bytes size each (containing uncompressed file data). If an archived file has a size in bytes which is not divideable by 512 without rest, as many bytes as missing to the next 512 byte boundary are added to fill up that last block. A file that is 513 bytes large thus occupies 512 bytes for the header, 513 bytes for the file's data, and 511 additional bytes so that the file content will be a multiple of 512 bytes (in this case, 1024 bytes). Tar was designed for tape devices which can be accessed only a block at a time. 512 bytes (half a kilobyte) was the standard size of a single block.
Compression types
None.
History
Tar (for tape archiver) was designed to create backups on tapes with Unix systems.
Popularity
Very high on Unix systems. "Tar balls" (a number of files stored in a single tar archive) are often used to distribute everything from simple utilities to the Linux kernel.
Often used in combination with gzip (and more recently bzip2) to reduce the size of the archives.
Meta data
The fixed-size (512 bytes) entry headers store name, size, date of last modification, access rights and more.
Limitations
No compression supported.
No support for extended character sets in file names.
Entry names can only be 100 characters long (including path).
Data recovery
Checksums are created only on the headers, so erroneous data will not be detected.
Encryption
Not supported.
Solid archives possible?
No. Tar does not support compression, so solid archiving (compressing more than one archive entry in a row) does not apply in the context of tar archives.
Support for multiple volumes?
No.
Libraries
GNU tar (implementation of the tar utility in C).
Java tar
Specification
tar(5) man page on Unix systems (Google finds those as well, try tar 5 man).