Linux Packaging Standard.tar.gz, .tgzMIME: application/gzip, application/x-tar

TAR.GZ Format Specification: The Linux & Open-Source Distribution Standard

Understand POSIX tape archive streaming, UNIX file permissions preservation, and GZIP deflate compression.

A TAR.GZ file (also abbreviated as .tgz) is an archive file created by concatenating multiple files into a single uncompressed Tape Archive (.tar) stream using POSIX standards, and subsequently compressing the resulting archive stream using GZIP (.gz) DEFLATE compression. It is the de facto standard for distributing source code, Linux software packages, container filesystem layers (Docker images), and server backups because it perfectly preserves UNIX file permissions, symlinks, and ownership metadata.

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 Typeapplication/gzip, application/x-tar
Standard / SpecificationPOSIX.1-2001 (pax format) / RFC 1952 (GZIP)
Initial Developer / OrganizationPOSIX / Free Software Foundation (GNU) (1979 (TAR) / 1992 (GZIP))
Header Structure512-byte POSIX ustar (Uniform Standard Tape Archive) records
Compression AlgorithmDEFLATE (RFC 1951) encapsulated in RFC 1952 GZIP container
Metadata PreservedLinux chmod permissions (755/644), UID/GID ownership, symlinks, mtime
Extraction Commandtar -xzvf archive.tar.gz

Operating System & Browser Compatibility Matrix

Where .tar.gz, .tgz is natively supported without third-party codecs:

Platform / EnvironmentNative SupportImplementation Notes
UNIX & Modern WindowsSupportedNative 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.