ubuntu, updated

Where are the logs?

The journal and /var/log: which log holds what, who may read it, and how log rotation works.

Two places

Ubuntu has two log systems running side by side:

systemd journal/var/log text files
WhatBinary log of the kernel and every serviceClassic text files written by rsyslog and some apps
Read withjournalctlless, grep, tail
ContainsEverything from systemd servicesMostly the same system messages, plus app logs (nginx, apache, mysql…)

Rule of thumb: for a service, ask the journal first (journalctl -u NAME). For web servers, databases and apps that write their own files, look in /var/log/APPNAME/.

Which log for what

QuestionLook in
Anything, by servicejournalctl -u SERVICE
General system messages/var/log/syslog
Logins, SSH, sudo, su/var/log/auth.log
Kernel: disks, drivers, OOM killerjournalctl -k or /var/log/kern.log, dmesg -T
Boot problemsjournalctl -b (this boot), journalctl -b -1 (previous)
Installed / removed packages/var/log/apt/history.log, /var/log/dpkg.log
Automatic updates/var/log/unattended-upgrades/
Cron jobsjournalctl -u cron
Firewall (ufw)/var/log/ufw.log
Web server/var/log/nginx/, /var/log/apache2/
Cloud VM first boot/var/log/cloud-init.log, /var/log/cloud-init-output.log
Login historylast, lastb (failed)

Who may read logs?

Most files in /var/log belong to group adm. Members of adm (and sudo) can read them without sudo. For the full journal, use group systemd-journal:

sudo usermod -aG adm,systemd-journal anna

Rotation: why there are .1 and .gz files

logrotate runs daily and renames old logs so they don’t fill the disk:

syslog          ← current
syslog.1        ← yesterday
syslog.2.gz     ← older, compressed

Use zgrep, zless or zcat for the .gz files. Settings: /etc/logrotate.conf and /etc/logrotate.d/.

The journal limits its own size (by default max. 10% of the file system). Check and clean:

journalctl --disk-usage
sudo journalctl --vacuum-time=30d      # delete entries older than 30 days

To keep the journal smaller permanently, set SystemMaxUse=500M in a file under /etc/systemd/journald.conf.d/.

Next: Searching logs.

§ home
~/knubertus/home/
1,1 Top