Learn how to compress and decompress files quickly from the shell. 20.03.2026 | reading time: 2 min On Linux the command `gzip` compresses files into the .gz format to save disk space and speed transfers; this short guide shows how to use it in daily workflows and scripts. Hands-on example Case: an engineer has a 2.1M log file named `report.log`; check `ls -lh report.log`, run `gzip report.log` and the original is replaced by `report.log.gz`, then `ls -lh report.log.gz` will show a much smaller size (for example 540K) and `gunzip report.log.gz` restores the original file. Options you will use Decompress with `gzip -d` or `gunzip`; use `gzip -c file > file.gz` to write compressed data to stdout and keep the original, or `gzip -k` to keep the original file; compress directories with `gzip -r somedir`; tune speed vs size with `-1` (fast) to `-9` (best); use `zcat` to stream compressed content without decompressing to disk. When gzip is not enough For stronger compression try `xz` or `bzip2`, for parallel speed use `pigz`, and for archives combine `tar` with gzip as `tar -czf archive.tar.gz`; remember that gzip does not encrypt data, so use `gpg` if confidentiality is required and prefer streaming in pipelines for remote transfers. Next steps gzip is simple but powerful: practice compressing files, experiment with compression levels and pipelines, then expand to related tools and consider formal study such as CompTIA Linux+ or LPIC-1 with intensive exam preparation at bitsandbytes.academy to turn skills into certification. Join Bits & Bytes Academy First class LINUX exam preparation. utilities storage backup scripting