gzip

Compress or decompress files using the GNU zip DEFLATE algorithm.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

gzip compresses a single file and replaces it with a .gz version. -k keeps the original. -d decompresses (same as gunzip). Compression level -1 (fastest) through -9 (best ratio). Combine with tar for multi-file archives.

Common flags
FlagMeaning
-d --decompressDecompress a .gz file (same as running gunzip)
-k --keepKeep the original file after compressing
-c --stdoutWrite output to stdout, don't replace file
-r --recursiveRecursively compress all files in a directory
-l --listShow compression ratio and sizes for .gz files
-1 --fastFastest compression, lowest ratio
-9 --bestBest compression ratio, slowest speed
-v --verboseShow compression ratio for each file processed
Examples
gzip -k -9 large_dump.sqlCompress SQL dump with best ratio, keeping the original file · explain & risk-check →
gzip -d archive.gzDecompress a .gz file back to its original form · explain & risk-check →
gzip -l *.gzShow compression stats (ratio, original vs compressed size) for all .gz files · explain & risk-check →
Pro tip

Use `zcat file.gz | grep pattern` to search inside a compressed file without decompressing it to disk first.

Related
gunzip tar bzip2 xz zcat
Open the full explainer →More in Files & Archives

Reference text is hand-written and may be incomplete — check man gzip for your version. Test destructive commands on a non-production system first.