Posted: . At: 12:41 PM. This was 4 years ago. Post ID: 14126
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to cat a gzipped logfile with gunzip properly.


The gunzip utility can uncompress logfiles that are gzipped in archives, but this is not needed. To read a logfile that is gzipped, you can also use this command to print the contents to a terminal and not bother uncompressing the file. This allows reading log files in /var/log without needing root access.

This is an example, reading an archived syslog file.

4.4 Thu Mar 05 jason@Yog-Sothoth 0: $ gunzip -k -c /var/log/syslog.6.gz | head -n 10
Feb 28 08:35:34 Yog-Sothoth rsyslogd:  [origin software="rsyslogd" swVersion="8.32.0" x-pid="1471" x-info="http://www.rsyslog.com"] rsyslogd was HUPed
Feb 28 08:37:01 Yog-Sothoth anacron[1802]: Job `cron.daily' terminated
Feb 28 08:37:01 Yog-Sothoth anacron[1802]: Normal exit (1 job run)
Feb 28 08:39:01 Yog-Sothoth CRON[8189]: Authentication failure
Feb 28 08:39:01 Yog-Sothoth cron[1979]: Authentication failure
Feb 28 08:39:04 Yog-Sothoth systemd[1]: Starting Clean php session files...
Feb 28 08:39:04 Yog-Sothoth systemd[1]: Started Clean php session files.
Feb 28 08:44:53 Yog-Sothoth systemd[1]: Starting Cleanup of Temporary Directories...
Feb 28 08:44:53 Yog-Sothoth systemd[1]: Started Cleanup of Temporary Directories.
Feb 28 08:45:01 Yog-Sothoth CRON[1828]: Authentication failure

Another example, using zcat. This also can read the contents of the file without the need to uncompress it first and then cat the extracted file.

4.4 Thu Mar 05 jason@Yog-Sothoth 0: $ zcat /var/log/syslog.6.gz | head -n 10
Feb 28 08:35:34 Yog-Sothoth rsyslogd:  [origin software="rsyslogd" swVersion="8.32.0" x-pid="1471" x-info="http://www.rsyslog.com"] rsyslogd was HUPed
Feb 28 08:37:01 Yog-Sothoth anacron[1802]: Job `cron.daily' terminated
Feb 28 08:37:01 Yog-Sothoth anacron[1802]: Normal exit (1 job run)
Feb 28 08:39:01 Yog-Sothoth CRON[8189]: Authentication failure
Feb 28 08:39:01 Yog-Sothoth cron[1979]: Authentication failure
Feb 28 08:39:04 Yog-Sothoth systemd[1]: Starting Clean php session files...
Feb 28 08:39:04 Yog-Sothoth systemd[1]: Started Clean php session files.
Feb 28 08:44:53 Yog-Sothoth systemd[1]: Starting Cleanup of Temporary Directories...
Feb 28 08:44:53 Yog-Sothoth systemd[1]: Started Cleanup of Temporary Directories.
Feb 28 08:45:01 Yog-Sothoth CRON[1828]: Authentication failure

This is a very good tip for finding errors in your Linux system. It appears that I have CRON deamon authentication errors, but I can fix these eventually.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.