Ubuntu – Where did the functionality of /var/log/dmesg go in xenial 16.04

16.04dmesgkernellogging

/var/log/dmesg was a useful boot time dmesg dump. I can’t find that any more in Ubuntu 16.04. Is it somewhere else?

(/var/log/kern.log* is limited; it catches kernel messages only after the logging daemon is running. Further is it cumbersome to find the right kern.log.X.gz file where the last boot happened. (It might have been rotated away, too.))

Best Answer

To show the output from the last boot, you can still use the command dmesg.

However, Ubuntu 16.04 (in fact all Ubuntus >=15.04) use systemd which has a logging daemon, journald and an interface with highly flexible access to logged data: journalctl. You can see a log of the last boot equivalent to dmesg:

journalctl -k

From journalctl man page:

-k, --dmesg Show only kernel messages. This implies -b and adds the match "_TRANSPORT=kernel"

all dmesg output in the last 2 hours

journalctl -k --since "2 hours ago"

all of the journal since last boot

journalctl -b

list boots in the journal

journalctl --list-boots

to set up persistent logging, you need to configure journald - by default its log is written non-persistently to /run/systemd/journal (a binary file - no use trying to read it) and no data is available before the current boot. To set up persistent logging, edit the file /etc/systemd/journald.conf and uncomment the line #Storage=auto and change auto to persistent. Use your favourite text editor or

sudo sed -i.bak 's/#Storage=auto/Storage=persistent/' /etc/systemd/journald.conf

Then you must restart the service (or reboot)

sudo systemctl restart systemd-journald

Having enabled persistent logging, you will in future be able to use the full functionality of journalctl for example, to see information from the boot before the current one

journalctl -b -2

See the relevant page of the wonderful <3 Arch Wiki <3 for further tips and tricks on using journalctl