history 19 of 36
Common Linux Log Files and What Each One Records
A list of common files in /var/log and what they contain, with the Red Hat vs Debian/Ubuntu differences and how to read logs with journalctl today.
Written
From my Linux study notes, 2015. Some commands and versions here are old, so please reuse them carefully. Anything marked "added later", and the notes at the end, explain what has changed since.
When something goes wrong on a Linux server, the logs are the first place to look. This is my list of common log files and what each is used for.
Before you start
- Most files in
/var/logcan only be read by root, so run the commands as root or withsudo. - Not every file exists on every system. The names depend on the distribution and on which software is installed (see the notes after the list).
Common Linux log files: name and usage
/var/log/messages: general messages and system-related events. (The original said/var/log/message; the correct name ismessages.) Used on Red Hat-family systems (CentOS, RHEL, Rocky Linux, AlmaLinux, Fedora)./var/log/auth.log: authentication logs (logins,sudo, SSH). Used on Debian and Ubuntu./var/log/kern.log: kernel logs. Used on Debian and Ubuntu./var/log/cron.log: crond logs (cron jobs). On Red Hat-family systems the file is/var/log/cron. On Debian and Ubuntu, cron messages go to/var/log/syslogunless a separatecron.loghas been enabled in the rsyslog configuration./var/log/maillog: mail server logs. This is the Red Hat-family name; Debian and Ubuntu use/var/log/mail.log./var/log/qmail/: qmail log directory (more files inside this directory). Only present if qmail is installed, and the location depends on how it was set up./var/log/httpd/: Apache access and error logs directory (Red Hat family). On Debian and Ubuntu it is/var/log/apache2/./var/log/lighttpd/: Lighttpd access and error logs directory./var/log/boot.log: system boot log./var/log/mysqld.log: MySQL database server log file. The location varies by version and package (MariaDB packages often use a different path); check thelog_errorsetting in your MySQL/MariaDB configuration./var/log/secure: authentication log. This is the Red Hat-family equivalent ofauth.log./var/log/utmpor/var/log/wtmp: login records files. Correction:wtmpis in/var/log/wtmpand holds login history, bututmp(who is logged in right now) is normally/var/run/utmp(/run/utmpon newer systems). These are binary files: read them withlast(wtmp) andwho(utmp), notcat. Failed logins are recorded in/var/log/btmp, read withsudo lastb./var/log/yum.log: yum log file (packages installed, updated and removed). On systems that usednf, look at/var/log/dnf.loginstead. On Debian and Ubuntu, package history is in/var/log/apt/history.logand/var/log/dpkg.log.
Red Hat family vs Debian/Ubuntu
| What | Red Hat family (CentOS, RHEL, Rocky, Alma) | Debian / Ubuntu |
|---|---|---|
| General system log | /var/log/messages |
/var/log/syslog |
| Authentication / SSH / sudo | /var/log/secure |
/var/log/auth.log |
/var/log/maillog |
/var/log/mail.log |
|
| Cron | /var/log/cron |
/var/log/syslog |
| Apache | /var/log/httpd/ |
/var/log/apache2/ |
Reading log files
Show the last 50 lines of a log:
sudo tail -n 50 /var/log/messagesFollow a log live while you reproduce a problem (press Ctrl+C to stop):
sudo tail -f /var/log/secureSearch a log for a word, for example failed SSH logins:
sudo grep "Failed password" /var/log/secureOn Debian or Ubuntu, use /var/log/auth.log in place of /var/log/secure in the last two examples.
Notes for today
-
The systemd journal. Systems that use systemd (CentOS 7 and later, Rocky Linux, AlmaLinux, current Debian and Ubuntu) also record logs in the systemd journal, read with
journalctl. The text files above are written by rsyslog; some newer installations do not install rsyslog by default, in which case the journal may be the only place to look. Useful commands:Terminal window sudo journalctl -u sshdsudo journalctl -fsudo journalctl -bsudo journalctl -p errThese show logs for one service (on Debian/Ubuntu the SSH unit is
ssh), follow new messages live, show messages since the last boot, and show only errors and worse. -
Log rotation. Old logs are renamed and compressed by
logrotate, so you may see files such asmessages-20250101orsyslog.1andsyslog.2.gz. Usezlessorzgrepto read the compressed ones. -
Kernel messages can also be read with
dmesg(may needsudo).