Forever & AlwaysLINUX COMMAND ATLAS

LINUX COMMAND ATLAS · COMMAND GUIDE

Linux gzip command

Compress a file with gzip. By default, the input file is replaced by its compressed form.

GNU Gzip

Syntax

Command form
gzip [OPTION]... [FILE]...

Common options

6 options
OptionWhat it does
-d, --decompressDecompress files.
-k, --keepKeep the input file instead of removing it.
-c, --stdoutWrite output to standard output and keep input files.
-r, --recursiveProcess files in directories recursively.
-1 to -9Set compression speed/size trade-off; -1 is faster, -9 smaller.
-v, --verboseShow compression ratio and file names.

Usage examples

2 examples

Compress a file with gzip. By default, the input file is replaced by its compressed form.

gzip -k report.log

Decompress a gzip file and keep the compressed original.

gzip -dk report.log.gz

Notes

By default gzip replaces input files with compressed files. Use -k or -c when the original must remain.