.GZ
Gzip compressed file
Introduction
Gzip compresses a single file with the DEFLATE method. Jean-loup Gailly and Mark Adler wrote it for the GNU project in 1992, and the format is described in RFC 1952. It is the standard compressor on Unix systems and is also used to compress web pages in transit.
Gzip holds one file, so a folder is first bundled with
tar and the tar file is then compressed. The result
is named .tar.gz, or .tgz for short.
Software
Structure
A gzip file is one or more members one after another; most files hold one. Numbers are little-endian.
0Magic1F 8B2 bytes2Method 8 for DEFLATE1 byte3Flags which optional fields follow1 byte4Modification time Unix seconds, or 04 bytes8Extra flags and operating system2 bytes10Optional fields extra data, original file name, comment, header CRCvaries…Compressed data a DEFLATE streamvaries…Trailer CRC-32 of the original data, then its size modulo 2328 bytes
The flag bits are 1 for text, 2 for a header CRC, 4 for an extra field, 8 for a file name and 16 for a comment. The name and comment are zero-terminated Latin-1 text. Because the size in the trailer wraps at 4 GiB, it gives the true size only for smaller files.