什么是 GZ (Gzip)?

了解GZ(Gzip)文件的功能及使用场景,全面指南涵盖GZ格式,无需上传。

免费在线文件转换工具。在 Windows、macOS、Linux、Android 和 iOS 上的 Chrome、Firefox、Safari、Edge、Opera 及其他现代浏览器中运行。无需安装软件或注册。所有转换都直接在您的浏览器中进行,因此您的文件不会离开您的设备。免费使用,无需账户。

GZ

什么是 GZ (Gzip)?

GZ (Gzip) 文件的完整指南 - 技术细节、优缺点、使用案例和常见问题

最后更新:

Year1992
TypeArchive
UsageLinux文件压缩

它是什么?

GZ (Gzip) 是一种文件压缩格式和软件程序,由 Jean-loup Gailly 和 Mark Adler 在 1992 年创建。它使用 DEFLATE 压缩算法,该算法结合了 LZ77 无损数据压缩和 Huffman 编码。Gzip 作为 Unix compress 程序的免费替代品而创建,后者采用的算法受专利保护。.gz 扩展名表示用 gzip 压缩的单个文件;对于目录存档,gzip 通常与 tar 结合使用以创建 .tar.gz 或 .tgz 文件。

Gzip 是 Linux 和 Unix 系统上的标准压缩工具,几乎内置于每个 Linux 发行版中。它广泛用于压缩日志文件、配置文件和软件包。Web 服务器使用 gzip 压缩来减小 HTML、CSS、JavaScript 和 JSON 响应的大小,然后再发送给浏览器,通常将文本内容的大小减少 60% 到 80%。gzip 格式包含一个简单的标头,其中包含文件名和修改时间,后跟压缩数据流。

技术规格

DevelopersJean-loup Gailly and Mark Adler
File Extension.gz /.gzip
MIME Typeapplication/gzip
AlgorithmDEFLATE (LZ77 + Huffman coding)
Single FileYes - compresses one file only (use tar for multiple)
StreamingYes - supports on-the-fly streaming compression
Toolsgzip command, zlib library, 7-Zip, WinRAR

优缺点

Advantages

标准 Linux 压缩

The universal compression standard on Unix and Linux - available on every system without installation.

快速压缩速度

DEFLATE compression is significantly faster than bzip2 or xz, making gzip suitable for frequent compression tasks.

Web 服务器压缩

Built-in web server feature for compressing HTTP responses, reducing page load times by 60 to 80% for text content.

流媒体友好

Supports single-pass streaming compression, making it ideal for compressing data in pipes and over networks.

Disadvantages

仅单个文件

Gzip compresses only one file at a time. To compress a directory, you must first create a tar archive.

压缩强度低于 bzip2 或 xz

DEFLATE provides good compression but bzip2 and xz consistently produce smaller files at the cost of slower processing.

不支持多卷

Does not support splitting compressed output across multiple files.

没有内部目录结构

Unlike ZIP or 7Z, a.gz file does not contain a directory listing - just compressed data for a single file.

何时使用

以下是 GZ (Gzip) 最适合的最常见情况:

Linux 日志压缩

Compress and archive log files on Linux servers using gzip to save disk space.

Linux 上的软件分发

Source code tarballs (.tar.gz) are the standard distribution format for open-source software.

Web 服务器优化

Configure Apache, Nginx, or other web servers to gzip HTML, CSS, and JavaScript responses automatically.

数据管道压缩

Use gzip in shell pipelines to compress data streams between processes without writing temporary files.

How to open a GZ file

GZ files, created using the Gzip compression algorithm, are commonly used for compressing single files or streams. Software for handling GZ files can be categorized into professional tools, free/open-source options, browser-based applications, and built-in utilities.

Professional tools are ideal for users needing advanced features and support, while free/open-source options cater to budget-conscious users or developers. Browser-based applications offer convenience for quick tasks, whereas built-in utilities provide basic functionality without additional installations.

When choosing software for GZ files, important factors include feature fidelity, whether the software is intended for editing or simply viewing, and the cost model. Users should consider platform compatibility, as some tools are limited to specific operating systems. Additionally, understanding when to convert GZ files to other formats can influence the choice of software, especially if the user needs to extract or manipulate the contents frequently.

7-Zip 22.01

Windows, macOS, LinuxFree (GPL)

7-Zip is a free and open-source file archiver that supports a wide range of compressed formats, including GZ. It allows users to extract and create GZ files with high fidelity, maintaining the integrity of the original data. The tool is particularly known for its high compression ratios and speed.

主要功能
  • Extracts GZ files quickly and efficiently
  • Supports multi-threaded compression
  • Integrates with Windows shell for easy access
  • Offers strong AES-256 encryption for archives
优点
  • Completely free with no limitations
  • High compression ratios compared to competitors
  • Supports a wide variety of file formats
局限
  • User interface may feel outdated
  • Limited support for advanced editing features

可导出为: ZIP, TAR, 7Z, XZ

适合: 7-Zip is ideal for users seeking a powerful, free tool to manage GZ files without any cost.

访问 7-Zip →

WinRAR 6.21

Windows, macOS, LinuxFree trial / One-time $29.00

WinRAR is a popular file compression tool that supports GZ files among many other formats. It provides a user-friendly interface for extracting and creating GZ archives, while also offering features like recovery records for damaged files. WinRAR is known for its robust performance and reliability.

主要功能
  • Creates and extracts GZ files seamlessly
  • Offers recovery options for corrupted archives
  • Supports multi-volume archives
  • Integrates with Windows Explorer for easy access
优点
  • User-friendly interface with extensive features
  • Reliable recovery options for damaged files
  • Regular updates and strong community support
局限
  • Paid software after trial period
  • Limited support for Linux users

可导出为: ZIP, RAR, TAR, CAB

适合: WinRAR is suitable for users who prefer a comprehensive and reliable tool for managing GZ files with a user-friendly interface.

访问 WinRAR →

PeaZip 9.3.0

Windows, LinuxFree (GPL)

PeaZip is a free file archiver that supports GZ files and offers a wide range of features for file management. It provides a graphical interface for extracting and creating GZ files, along with advanced options for file encryption and secure deletion. PeaZip is particularly favored for its versatility and open-source nature.

主要功能
  • Extracts and creates GZ files easily
  • Supports over 180 archive formats
  • Offers strong file encryption options
  • Includes file integrity checks
优点
  • Completely free and open-source
  • Supports a vast array of formats
  • Advanced security features for sensitive files
局限
  • Interface may be complex for beginners
  • Performance can lag with large files

可导出为: ZIP, TAR, 7Z, ARC

适合: PeaZip is perfect for users looking for a free, versatile tool that handles GZ files and offers advanced security features.

访问 PeaZip →

The Unarchiver 4.3.0

macOSFree

The Unarchiver is a free extraction tool for macOS that supports GZ files among many other formats. It is designed to be a simple and effective solution for extracting compressed files, ensuring that users can easily access their content without hassle. The Unarchiver focuses on ease of use and compatibility with various archive formats.

主要功能
  • Extracts GZ files with a simple drag-and-drop
  • Handles a wide range of archive formats
  • Preserves file attributes during extraction
  • Integrates seamlessly with macOS Finder
优点
  • Extremely user-friendly for macOS users
  • Fast extraction speeds
  • Supports many archive formats beyond GZ
局限
  • Limited to extraction, no creation of GZ files
  • Not available on Windows or Linux

可导出为: None (extraction only)

适合: The Unarchiver is ideal for macOS users who need a straightforward tool for extracting GZ files without additional complexity.

访问 The Unarchiver →

转换 GZ (Gzip) 文件

需要转换你的 GZ 文件?使用我们的免费在线转换器。

Convert GZ (Gzip) Files

参考资料

  1. GZIP File Format - RFC 1952 (IETF)
  2. GZIP - Library of Congress
  3. gzip - Wikipedia

关于 GZ (Gzip) 的常见问题

.gz 和 .tar.gz 有什么区别?

.gz 文件是用 gzip 压缩的单个文件。.tar.gz (或 .tgz) 文件是多个文件和目录的 tar 档案,已用 gzip 压缩。大多数 Linux 软件以 .tar.gz 包的形式分发。

gzip 和 ZIP 是一样的吗?

不是。Gzip 和 ZIP 都使用 DEFLATE 算法,但它们是不同的格式。ZIP 是一个容器,可以保存多个文件并单独压缩。Gzip 压缩单个文件;它与 tar 一起用于多文件档案。

如何在 Linux 上解压 .gz 文件?

使用命令: gunzip filename.gz - 或: gzip -d filename.gz - 对于 .tar.gz 文件: tar -xzf filename.tar.gz

我可以在 Windows 上打开 GZ 文件吗?

可以。7-Zip、WinRAR 和 WinZip 可以在 Windows 上提取 .gz 文件。这些应用程序可以处理 .gz 和 .tar.gz 文件。

我应该使用什么压缩级别?

默认 gzip 压缩级别 (9 中的 6) 提供了速度和大小的良好平衡。当大小至关重要且速度不是优先考虑时,使用 -9 获得最大压缩。