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, --stdoutwrite on standard output, keep original files unchanged-d, --decompressdecompress-f, --forceforce overwrite of output file and compress links-h, --helpgive this help-l, --listlist compressed file contents-L, --licensedisplay software license-n, --no-namedo not save or restore the original name and time stamp-N, --namesave or restore the original name and time stamp-q, --quietsuppress all warnings-r, --recursiveoperate recursively on directories-S, --suffix=SUFuse suffix SUF on compressed files-t, --testtest compressed file integrity-v, --verboseverbose mode-V, --versiondisplay version number-1, --fastcompress faster-9, --bestcompress better--rsyncableMake rsync-friendly archive
With no FILE, or when FILE is -, read standard input.