Ffile2fix
Sign in Get started

What is a .gz file?

A .gz file is a single file compressed with gzip. You meet it as rotated server logs (access.log.2.gz), compressed SQL dumps (backup.sql.gz) and, combined with tar, as .tar.gz source archives.

Key facts

  • Gzip compresses exactly one file with DEFLATE; to bundle several files you need tar first, giving .tar.gz.
  • MIME type is application/gzip; files start with the bytes 1F 8B.
  • The trailer stores a CRC-32 and the original size (modulo 4 GB), so gzip -t can detect corruption.
  • The same compression is used for HTTP Content-Encoding: gzip on web servers.
  • Created by gzip, logrotate, mysqldump pipelines and backup scripts.

How to open a .gz file

Windows

Open it with 7-Zip and extract the file inside. For a .tar.gz, the built-in tar -xzf file.tar.gz command also works.

macOS

Double-click to decompress it with Archive Utility, or run gunzip -k file.gz in Terminal to keep the original.

Linux

Run gunzip -k file.gz to decompress, or zcat file.gz and zless file.gz to read it without unpacking.

Common problems and fixes

"gzip: file.gz: not in gzip format"
The file is not gzip, despite the name: it may be plain text, a ZIP or an HTML error page. Run file file.gz to check the real type.
"unexpected end of file"
The file is truncated from an interrupted transfer. Download or copy it again; zcat can still print the readable start if you need partial data.
"crc error" or "invalid compressed data"
The compressed bytes are damaged. Run gzip -t file.gz to confirm, then restore it from the source or another backup.
gunzip deleted my original .gz file
That is gunzip's default behaviour. Use gunzip -k (keep) or zcat file.gz > file to leave the compressed copy in place.

Often converted to or from: TAR.GZ, ZIP, XZ, BZ2, plain file

Frequently asked questions

What is the difference between .gz and .tar.gz?

A .gz holds one compressed file. A .tar.gz first packs many files into a tar archive and then gzips it, so it can hold whole folders.

How do I import a .sql.gz database dump?

Stream it straight into the client without unpacking, for example gunzip < backup.sql.gz | mysql -u user -p dbname. phpMyAdmin can also import .sql.gz files directly.

How do I search inside a .gz log file?

Use zgrep 'pattern' access.log.2.gz, which decompresses on the fly. zless and zcat work the same way for reading.

See all file types β†’ Β· Browse error fixes β†’