When running a system based on linux, one has to check what’s going on from time to time. Often current messages from the kernel are important, which can be accessed with dmesg or journalctl. Some notes about how to use …

The kernel outputs important messages to the so-called Kernel Ring Buffer. Sounds fancy but actually is just a special way of logging stuff. While I often use tail -f on logfiles, this doesn’t work here as one might expect. While there is a /var/log/dmesg and you can look into it with cat:

root@bs:~# tail /var/log/dmesg
[...]
[    2.986690] Installing knfsd [...]
root@bs:~# 

You could also use the -f option if you like, but it will show you something different than the command dmesg:

root@bs:~# dmesg
[...]
[2547712.883082] fuse init (API version 7.23)
root@bs:~# 

So you are stuck to using special commands. Now these commands provide customisation options. To achieve the the same as with the tail command, i.e. keep showing messages as they come up, you can call dmesg like this:

root@bs:~# dmesg -w
[...]
[2547712.883082] fuse init (API version 7.23)

You will need to end it with something like Ctrl+C as with the tail -f. Now while we are at it, while those timestamps are accurate I often prefer a readable time. Easy with Option -T:

root@bs:~# dmesg -wT
[...]
[Fr Okt 23 11:21:46 2015] fuse init (API version 7.23)

With systemd another command has become available for this task, journalctl. If used without options, it will show you all journal entries. If you want to restrict to the kernel messages as shown by dmesg, you can add option -k. And then you use -f as used to from tail, giving you:

root@bs:~# journalctl -kf
[...]
Okt 23 11:21:47 bs kernel: fuse init (API version 7.23)

Sounds good? I need to be root to use journalctl. While dmesg can be called as any user, most logs in /var/log are readable only for root anyways, so that’s no problem for me. But remember this if you get to this and wonder what’s going on:

user@bs:~# journalctl -kf
No journal files were found.
user@bs:~#