zcat and zless on Linux: Read Gzip Logs Without Extracting

zcat zless linux - custom-zless-featured.png

Operators grep live logs with grep but rotated files end in .gz — zless and zcat avoid decompressing to /tmp. Works alongside smartctl job logs.

Page through gzip

zless behaves like less on compressed files.

bashzless
zless /var/log/syslog.2.gz
zless
pager

Dump to stdout

zcat for scripts and pipes.

bashzcat
zcat /var/log/nginx/access.log.1.gz | head
zcat
pipe

Search compressed

zgrep for ERROR across rotations.

bashzgrep
zgrep -h 'POST /api' /var/log/nginx/access.log*.gz | tail
zgrep
ERROR

Avoid full gunzip

Only gunzip when you must edit the file in place.

TipOn low-disk VPS, never gunzip multi-GB logs — stream with zcat into files you delete after.
gunzip
compare

Quick Reference

  • Read: zless file.gz
  • Pipe: zcat file.gz | grep
  • Search: zgrep pattern file.gz

Related tutorials

Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.