GZ - Gnu Zipped Archive

Last modified by Farooq Sheikh on 2019/10/11 06:07

Files with .GZ extension are compressed files created with gzip compression application. It can contain multiple compressed files and is commonly used on UNIX and Linux systems. GZIP was introduced as a free utility for replacing the Compress program used in Unix systems. Such files can be opened and extracted with a several applications such as WinZip which is available on both Windows and MacOS. While the format is similar to .ZIP compression in archiving, it differs in terms of compression applied to the archive instead of individual file.

GZ File Format

Gzip uses the DEFLATE algorithm for compression of archive and differs from the .ZIP archive format in applying the compression algorithm on complete archive rather than individual files. The GZIP file format specifications version 4.3 published by Internet Engineering Task Force (IETF) contains detailed information about the file format. The file format consists of:

  • File Header
  • Optional Headers
  • Compressed Data
  • File Footer

File Header

The file header consists of 10 bytes as follow:

020x1f 0x8bMagic number identifying file type

Compression Method

  • 0-7 (Reserved)
  • 8 (Deflate)

File Flags 

44 32-bit timestamp
81 Compression flags
91 Operating system ID

File Flags

0x01FTEXTIf set the uncompressed data needs to be treated as text instead of binary data. 
This flag hints end-of-line conversion for cross-platform text files but does not enforce it.
0x02FHCRCThe file contains a header checksum (CRC-16)
0x04FEXTRAThe file contains extra fields
0x08FNAMEThe file contains an original file name string
0x10FCOMMENTThe file contains comment
0x20 Reserved
0x40 Reserved
0x80 Reserved

Operating System

0FAT filesystem (MS-DOS, OS/2, NT/Win32)
2VMS (or OpenVMS)
5Atari TOS
6HPFS filesystem (OS/2, NT)
11NTFS filesystem (NT)
13Acorn RISCOS

Optional Headers

The optional extra headers are those as denoted by the file flags and include information such as the original filename, extra fields, comments and header checksum.

Compressed Data

This section contains the compressed data using the DEFLATE compression algorithm.

File Footer

The file footer is 8 bytes in size and contains following information.

04Checksum (CRC-32)
44Uncompressed data size value in bytes


Created by Kashif Iqbal on 2019/09/10 02:58