7

/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.))

  • Does dmesg | head -n 100 give you the boot time messages you want? If so, unbuffer dmesg | head -n 100 will do it in color. – Chai T. Rex Dec 12 '16 at 11:57
  • If /var/log/kern.log* is limited try /var/log/syslog* instead. – WinEunuuchs2Unix Dec 12 '16 at 12:04
14

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

  • 1
    As I said, dmesg might not show boot time info any more (if it is out of the kernel ring buffer already). But journalctl -k seems to be complete. – Robert Siemer Feb 9 '17 at 11:18
  • Also note that timestamps in journalctl -k output are not consistent with time offsets in dmesg output. In my case dmesg is showing a ~30 second delay during boot which journalctl -k does not between the same two log lines. – TaisPH Aug 2 '18 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.