Beginner Package: gzip

gzip

Compress a file using the gzip algorithm.

Syntax

gzip [options] file

Description

gzip compresses a single file in place, replacing it with a .gz version (use -k to keep the original), and is one of the most common compression formats on Linux, often paired with tar for whole directories.

Examples

gzip file.txt
Compress a file to file.txt.gz, removing the original
gzip -k file.txt
Compress but keep the original file too
gzip -9 file.txt
Compress with maximum (slowest) compression level

Applies to

Ubuntu Debian Linux Mint RHEL CentOS / Rocky / AlmaLinux Fedora Arch Linux openSUSE Alpine Linux