TAR.GZ Format Specification: The Linux & Open-Source Distribution Standard
Understand POSIX tape archive streaming, UNIX file permissions preservation, and GZIP deflate compression.
Format Specification & Header Signature
Core file signatures, developer metadata, and standard RFC specifications:
| Magic Bytes (Hex Signature) | 1F 8B 08 (gzip ID1, ID2, CM) |
| MIME Media Type | application/gzip, application/x-tar |
| Standard / Specification | POSIX.1-2001 (pax format) / RFC 1952 (GZIP) |
| Initial Developer / Organization | POSIX / Free Software Foundation (GNU) (1979 (TAR) / 1992 (GZIP)) |
| Header Structure | 512-byte POSIX ustar (Uniform Standard Tape Archive) records |
| Compression Algorithm | DEFLATE (RFC 1951) encapsulated in RFC 1952 GZIP container |
| Metadata Preserved | Linux chmod permissions (755/644), UID/GID ownership, symlinks, mtime |
| Extraction Command | tar -xzvf archive.tar.gz |
Operating System & Browser Compatibility Matrix
Where .tar.gz, .tgz is natively supported without third-party codecs:
| Platform / Environment | Native Support | Implementation Notes |
|---|---|---|
| UNIX & Modern Windows | Supported | Native tar command on Linux, macOS, and modern Windows 10/11 PowerShell. |
Advantages of Gzipped Tape Archive
- •Preserves exact Linux file system permissions, symbolic links, and timestamps essential for code compilation
- •Solid compression: compresses across file boundaries, producing significantly smaller archives for repetitive source files
- •Streamable: can be created and unpacked in a continuous pipeline without storing intermediate files on disk
Limitations & Trade-Offs
- •Zero random access: extracting a single file requires sequentially decompressing all data up to that file
- •Native Windows Explorer GUI requires third-party tools (7-Zip) or terminal tar commands to view
- •Corrupting an early byte in the GZIP stream can prevent decompression of all subsequent files
The 512-Byte Header Block Architecture
A TAR file consists of consecutive 512-byte blocks. Each archived file begins with a header block containing the file name, file mode (permissions), owner ID, group ID, size in octal representation, and an 8-byte checksum.
File contents follow in 512-byte chunks, padded with null bytes. Two consecutive 512-byte blocks of binary zeroes signify the end of the archive stream.
Frequently Asked Questions about Gzipped Tape Archive
What do the flags in tar -xzvf mean?
`-x` stands for extract, `-z` filters the archive through gzip decompression, `-v` enables verbose file progress output, and `-f` specifies the target archive filename.
Why do Docker image layers use tar.gz?
Because tar.gz faithfully captures POSIX root permissions (`chmod 755 /etc`), hard links, and file timestamps required for deterministic Linux container runtimes.