gzip
Compress files to reduce their size
TLDR
Compress a file, replacing it with a gzip archive
Decompress a file, replacing it with the original uncompressed version
Compress a file, keeping the original file
Compress a file, specifying the output filename
Decompress a gzip archive specifying the output filename
Specify the compression level. 1 is the fastest (low compression), 9 is the slowest (high compression), 6 is the default
Display the name and reduction percentage for each file compressed or decompressed
SYNOPSIS
gzip [options] [file...]
PARAMETERS
-d or --decompress or --uncompress
Decompress the specified files.
-c or --stdout or --to-stdout
Write output on standard output; keep original files unchanged.
-f or --force
Force compression or decompression even if the file has multiple links or if a file already exists.
-h or --help
Display a help screen and exit.
-l or --list
List compressed file contents.
-n or --no-name
When compressing, do not save the original file name and timestamp.
-N or --name
When compressing, save the original file name and timestamp (default).
-q or --quiet
Suppress all warnings.
-r or --recursive
Operate recursively on directories.
-t or --test
Test compressed file integrity.
-v or --verbose
Print verbose output.
-1 or --fast
Use the fastest compression method (least compression).
-9 or --best
Use the best compression method (slowest compression).
--rsyncable
Compress so that rsync can delta-transfer the compressed file if the original file has changed.
DESCRIPTION
gzip is a command-line utility used for compressing and decompressing files. It reduces the size of files using the Lempel-Ziv coding (LZ77).
When compressing, gzip typically replaces the original file with a file ending in '.gz'. The original file can be recreated using gzip -d or gunzip. gzip attempts to compress the whole file at once. The amount of compression depends on the size of the input file and distribution of common substrings.
A compressed file contains, besides the compressed data, the name and timestamp of the original file, recovery of disk space usage and consistency check.
CAVEATS
gzip compresses individual files and doesn't archive them. For archiving and compression, use tar combined with gzip (e.g., tar -czvf archive.tar.gz directory).
EXIT STATUS
The exit status is normally 0. If an error occurs, the exit status is 1 or greater.
ENVIRONMENT
The environment variable GZIP can be used to set default options for gzip. For example: GZIP="-9vr" sets the compression level to the best, enables verbose mode, and operates recursively on directories.
HISTORY
gzip was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program, which was patented. The first version was released on October 31, 1992.
It quickly became the standard compression tool on Unix-like systems due to its efficiency and open-source nature.