Practical ways to read rotated and compressed log files without breaking rotation. 16.11.2025 | reading time: 2 min Rotated logs pile up fast; he must know how to peek into old compressed files without altering rotation or decompressing everything. A quick real-world case A web service failed overnight and yesterday's logs are in a gzip-rotated file; reproduce the investigation with these commands: ```\n$ ls -l /var/log/myapp/\n-rw-r----- 1 root adm 2048 Aug 15 02:00 access.log\n-rw-r----- 1 root adm 1024 Aug 14 02:00 access.log.1.gz\n\n$ zgrep "ERROR" /var/log/myapp/access.log.1.gz\nAug 14 01:45:12 myhost myapp[123]: ERROR: cannot connect to DB\nAug 14 02:01:00 myhost myapp[123]: ERROR: timeout while reading\n``` Commands that get results fast Do it rather than theorize: `zless` opens compressed files in a pager, `zcat` streams contents, and `zgrep` searches inside compressed archives; examples shown here: ```\n# view compressed file with pager\nzless /var/log/myapp/access.log.1.gz\n\n# stream and tail the last 50 lines\nzcat /var/log/myapp/access.log.1.gz | tail -n 50\n\n# search with line numbers\nzgrep -n "timeout" /var/log/myapp/access.log.1.gz\n\n# handle bzip2 and xz variants\nbzcat file.log.1.bz2 | less\nxzcat file.log.1.xz | less\n``` Edge cases to watch Rotation method matters: files compressed with `logrotate` and the default gzip are read easily, but `copytruncate` means the active file is truncated while a copy is saved; following a live file across rotations needs different tooling than inspecting an archived `.gz` file, so use streaming (`zcat | tail`) for snapshots and check `logrotate` config when entries are missing. Other tools in the toolbox Beyond gzip-aware commands, remember `journalctl` for systemd binary journals, `logrotate` for rotation rules, and `multitail` or `less +F` variants for watching logs across rotations; choose the tool that matches the file format and whether the log is active or archived. Wrap up and next move Learning to inspect rotated logs reliably saves hours of guessing; sharpen that skill by practicing on compressed files, exploring rotation configs, and preparing for deeper Linux certification with focused courses such as bitsandbytes.academy which help toward CompTIA Linux+ and LPIC-1. Join Bits & Bytes Academy First class LINUX exam preparation. utilities filesystem troubleshooting