Skip to content

Linux Logs

Most logs live under /var/log/. Some systems use journalctl (systemd journal) instead of or alongside traditional log files.

Log filePurpose
/var/log/syslogGeneral system activity (Debian/Ubuntu)
/var/log/messagesGeneral system activity (RHEL/CentOS)
/var/log/dmesgKernel ring buffer — hardware, drivers, boot messages
/var/log/kern.logKernel messages
/var/log/boot.logBoot process output
Log filePurpose
/var/log/auth.logAuthentication events — logins, sudo, SSH (Debian/Ubuntu)
/var/log/secureSame purpose (RHEL/CentOS)
/var/log/faillogFailed login attempts
/var/log/lastlogLast login for each user (binary — read with lastlog)
/var/log/wtmpLogin/logout records (binary — read with last)
/var/log/btmpFailed login records (binary — read with lastb)
Log filePurpose
/var/log/apache2/Apache access and error logs
/var/log/nginx/Nginx access and error logs
/var/log/mysql/MySQL/MariaDB logs
/var/log/mail.logMail server logs
/var/log/cron.logCron job execution (or grep CRON /var/log/syslog)
/var/log/ufw.logUFW firewall logs
Log filePurpose
/var/log/dpkg.logPackage install/remove (Debian/Ubuntu)
/var/log/yum.logPackage activity (RHEL/CentOS)
/var/log/apt/APT activity logs

Terminal window
tail -f /var/log/syslog # Follow in real-time
tail -n 50 /var/log/auth.log # Last 50 lines
Terminal window
grep "Failed password" /var/log/auth.log
grep "sshd" /var/log/auth.log | tail -20
grep -i "error" /var/log/syslog | grep "$(date +%b\ %d)"
Terminal window
last # Login history (reads /var/log/wtmp)
last -n 10 # Last 10 logins
lastb # Failed logins (reads /var/log/btmp, root only)
lastlog # Last login per user (reads /var/log/lastlog)
who # Currently logged-in users
w # Currently logged-in users with activity

On systemd-based systems, journalctl queries the systemd journal — which aggregates logs from all services.

Terminal window
journalctl # All journal entries
journalctl -f # Follow in real-time
journalctl -u sshd # Logs for a specific service
journalctl -u nginx --since "1 hour ago"
journalctl -p err # Only errors and above
journalctl --since "2026-03-01" --until "2026-03-02"
journalctl -b # Current boot only
journalctl -b -1 # Previous boot
journalctl _UID=1000 # Logs from a specific user
journalctl --disk-usage # How much space journal uses

Priority levels: emerg, alert, crit, err, warning, notice, info, debug.


Quick checks during recon or incident response:

Terminal window
# SSH brute force attempts
grep "Failed password" /var/log/auth.log | wc -l
# Successful SSH logins
grep "Accepted" /var/log/auth.log
# sudo usage
grep "sudo" /var/log/auth.log
# User creation/modification
grep "useradd\|usermod\|passwd" /var/log/auth.log
# Cron activity
grep "CRON" /var/log/syslog
# Recently modified files in sensitive locations
find /etc -mtime -1 -type f 2>/dev/null

Logs are rotated (compressed, archived, eventually deleted) by logrotate:

Terminal window
cat /etc/logrotate.conf # Global config
ls /etc/logrotate.d/ # Per-service configs

Rotated logs are typically named syslog.1, syslog.2.gz, etc. Check rotated files too when investigating.