๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

๐Ÿ’ก Compression & Archives October 2, 2026 12

Linux Command: gunzip

Decompress .gz files

Terminal โ€” Compression & Archives
Command
$ gunzip access.log.gz

gunzip decompresses files compressed with gzip. It is equivalent to gzip -d. gunzip replaces the .gz file with the decompressed original by default. gunzip can also decompress files created by compress (.Z files) and pack (.z files). It handles multiple files and supports keeping the original compressed file. For viewing compressed files without decompressing, use zcat (or zless, zgrep) instead.

Syntax

gunzip [OPTION]... [FILE]...

Key Options

  • -k โ€” Keep compressed file
  • -f โ€” Force decompression (overwrite existing)
  • -r โ€” Recursively decompress
  • -l โ€” List compressed file info
  • -v โ€” Verbose output
  • -c โ€” Write to stdout (keep original)

Examples

Decompress file

gunzip access.log.gz

Keep original

gunzip -k backup.sql.gz

Decompress to stdout

gunzip -c data.csv.gz | head -10

Pro Tips

  • Use zcat file.gz to view contents without decompressing. Or zless for paging, zgrep for searching.
  • gunzip is exactly the same as gzip -d. Use whichever you remember.
  • gunzip removes the .gz file by default. Use -k to keep it.

Learn more: Full gunzip reference โ†’

Share this tip