How to use the gzip command in Linux


Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modi‐fication times.

gzip -k
gzip --help
gzip -h
info gzip
man gzip
version information
gzip --version
gzip -V
gzip 1.5

Compressing Files with gzip

Keep the original file
gzip -k
gzip -c >
Verbose output
gzip -v
multiple files
gzip file1 file2 file3
gzip -r folder
standard input
history | gzip -c > history.gz
gzip -d -18.2% -- replaced with

The syntax for the gzip command is as follows:

  gzip [OPTION]... [FILE]...

-c, --stdout
write on standard output, keep original files unchanged
-d, --decompress
-f, --force
force overwrite of output file and compress links
-h, --help
give this help
-l, --list
list compressed file contents
-L, --license
display software license
-n, --no-name
do not save or restore the original name and time stamp
-N, --name
save or restore the original name and time stamp
-q, --quiet
suppress all warnings
-r, --recursive
operate recursively on directories
-S, --suffix=SUF
use suffix SUF on compressed files
-t, --test
test compressed file integrity
-v, --verbose
verbose mode
-V, --version
display version number
-1, --fast
compress faster
-9, --best
compress better
Make rsync-friendly archive

With no FILE, or when FILE is -, read standard input.

Related Tags

#Linux# #gzip#