← 返回命令列表

Linux command

gzip 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Compress a file

gzip [file]

Decompress a file

gzip -d [file.gz]

Compress keeping original file

gzip -k [file]

Compress with best compression

gzip -9 [file]

Compress with fastest speed

gzip -1 [file]

List compression information

gzip -l [file.gz]

Test compressed file integrity

gzip -t [file.gz]

Compress to stdout

gzip -c [file] > [file.gz]

Decompress to stdout

gzip -dc [file.gz]

说明

gzip compresses files using the Lempel-Ziv coding (LZ77) algorithm. Each file is replaced by a compressed version with a .gz extension, preserving ownership, modes, and timestamps. By default, gzip removes the original file after compression. Compressed files can be restored using gzip -d (or gunzip). The tool can also compress data from stdin and write to stdout for pipeline use. gzip is widely supported and commonly used for compressing individual files, creating archives with tar, and transferring data. The format is defined in RFC 1952.

参数

-d, --decompress
Decompress files.
-c, --stdout
Write to stdout, keep original files.
-k, --keep
Keep original files.
-l, --list
List compression info.
-t, --test
Test integrity.
-f, --force
Force compression/decompression.
-r, --recursive
Recurse into directories.
-n, --no-name
Don't save original name/timestamp.
-N, --name
Save/restore original name/timestamp.
-1 to -9
Compression level (fast to best).
--best
Maximum compression (-9).
--fast
Fastest compression (-1).
-v, --verbose
Verbose output.
-q, --quiet
Suppress warnings.

FAQ

What is the gzip command used for?

gzip compresses files using the Lempel-Ziv coding (LZ77) algorithm. Each file is replaced by a compressed version with a .gz extension, preserving ownership, modes, and timestamps. By default, gzip removes the original file after compression. Compressed files can be restored using gzip -d (or gunzip). The tool can also compress data from stdin and write to stdout for pipeline use. gzip is widely supported and commonly used for compressing individual files, creating archives with tar, and transferring data. The format is defined in RFC 1952.

How do I run a basic gzip example?

Run `gzip [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -d, --decompress do in gzip?

Decompress files.