13

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

fosslinux
  • 3,881

1 Answers1

24

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

Pablo Bianchi
  • 17,552
Zanna
  • 72,471
  • 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 09 '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 02 '18 at 12:42
  • So you say journalctl -k is completley equivalent to dmesg? – sancho.s ReinstateMonicaCellio Jul 27 '21 at 09:52