How to use the gzip command in Linux

Created

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.

Compress
gzip -k filename.md
Help
gzip --help
gzip -h
info gzip
man gzip
version information
gzip --version
gzip -V
filename.md.gz
gzip 1.5

Compressing Files with gzip

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

The syntax for the gzip command is as follows:

Usage: 
  gzip [OPTION]... [FILE]...

OPTIONS:
-c, --stdout
write on standard output, keep original files unchanged
-d, --decompress
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
--rsyncable
Make rsync-friendly archive

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

Related Tags

#Linux# #gzip#