Read and Filter Kernel Logs With dmesg and journalctl -k
Read the kernel ring buffer with dmesg and the journal with journalctl -k, filter by level and time, follow new messages and avoid clock and permission traps.

When a driver fails to load, a disk throws errors or a machine reboots on its own, the explanation is usually already in the kernel log. Two commands read it: dmesg reads the kernel's in-memory ring buffer, and journalctl -k reads the same messages as stored by systemd-journald. They overlap and differ in important ways: one is gone at reboot, the other can persist; one has simple filters, the other has a query language. This post shows the options you will actually use on a Linux 6.12 system with a recent util-linux and systemd, how to filter by severity and time, how to follow a log live, and the limits that trip people up. The log's source side, with levels, is covered in the printk levels post.
Where the log lives
The kernel writes every printk() message into a ring buffer in memory. The buffer has a fixed size, and when it fills, the oldest messages are overwritten. dmesg reads that buffer through /dev/kmsg (or the older syslog() system call). It shows only what the buffer still holds, since the last boot, and a restart clears it.
systemd-journald reads the same stream continuously and stores it in the journal, adding fields such as the boot id and the priority. If the journal is configured as persistent, with Storage=persistent in /etc/systemd/journald.conf or a /var/log/journal directory, messages survive reboots and you can read the previous boot. With the default auto setting, a missing /var/log/journal means volatile storage under /run, which is lost at reboot like the ring buffer.
Check which you have:
ls -d /var/log/journal 2>/dev/null || echo "journal is volatile"
journalctl --list-boots | tail -n 3/var/log/journal
-2 3a1b... Fri 2026-11-20 08:12:03 UTC—Sat 2026-11-21 19:40:55 UTC
-1 9c4d... Sat 2026-11-21 19:41:30 UTC—Sun 2026-11-22 22:03:12 UTC
0 5e7f... Sun 2026-11-22 22:03:50 UTC—Mon 2026-11-23 09:15:01 UTCBoot ids and times differ on your machine. More than one line means the journal is persistent and you can read earlier boots.
dmesg basics
dmesg | head -n 3[ 0.000000] Linux version 6.12.0 (builder@host) (gcc (GCC) 14.2.1) #1 SMP PREEMPT_DYNAMIC Fri Nov 14 10:12:41 UTC 2026
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-6.12.0 root=/dev/sda2 ro quiet
[ 0.000000] BIOS-provided physical RAM map:The number in brackets is seconds since the kernel started its clock, with microseconds. The options that matter:
| Option | Effect |
|---|---|
-T, --ctime | Print human-readable wall-clock times |
-H, --human | Human output: pager, color, relative times, delta |
-w, --follow | Wait for new messages, like tail -f |
-W, --follow-new | Follow only messages that arrive after the command starts |
-l, --level LIST | Restrict to levels, comma separated |
-f, --facility LIST | Restrict to facilities such as kern or daemon |
-x, --decode | Show facility and level as words |
-r, --raw | Show the raw message with the <N> prefix |
-k, --kernel | Kernel messages only (the default facility set) |
--since, --until | Time range, on recent util-linux releases |
-c, --read-clear | Print, then clear the buffer (root) |
-C, --clear | Clear the buffer without printing (root) |
-n LEVEL | Set the console loglevel (root) |
Combine a level filter with human times to see recent problems:
dmesg -T --level=err,warn | tail -n 4[Mon Nov 23 09:14:02 2026] nvme nvme0: missing or invalid SUBNQN field.
[Mon Nov 23 09:14:07 2026] ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.XHC.PS0], AE_NOT_FOUND
[Mon Nov 23 09:14:09 2026] usb 1-3: device descriptor read/64, error -71
[Mon Nov 23 09:21:45 2026] ticker: fifo overrunLevel names are emerg, alert, crit, err, warn, notice, info and debug. A comma list selects exactly those, and the form --level=err+ for "err and more severe" works on recent util-linux, but older versions need the explicit list, so check dmesg --help on your machine.
The clock caveat of -T
-T converts the monotonic timestamp to wall-clock time by subtracting the time since boot from the current time. That is only right if the monotonic clock kept counting during the whole uptime. The kernel's log clock does not advance while the machine is suspended, so after a suspend and resume, dmesg -T shows times that are too early by the total suspend duration. The man page warns about this. For accurate times, use journalctl, which records the real wall-clock time when it receives each message, or dmesg --time-format=iso on a machine that never suspends. Treat -T as approximate on laptops.
Follow a log live
To watch messages arrive while you plug in a device, use -w with a filter:
sudo dmesg -wH --level=err,warn,info[Nov23 09:30] usb 1-2: new high-speed USB device number 7 using xhci_hcd
[ +0.120000] usb 1-2: New USB device found, idVendor=0781, idProduct=5581
[ +0.000001] usb-storage 1-2:1.0: USB Mass Storage device detected-H prints the delta from the previous message in brackets, which is useful for spotting a long gap, such as a driver waiting for a timeout. Press Ctrl-C to stop. -W starts from the present instead of replaying the buffer first.
journalctl -k
The journal's kernel messages are selected by -k or --dmesg. The output has syslog-like timestamps and the host name:
journalctl -k -b -n 3 --no-pagerNov 23 09:21:45 host kernel: ticker: fifo overrun
Nov 23 09:25:10 host kernel: usb 1-2: new high-speed USB device number 8 using xhci_hcd
Nov 23 09:25:10 host kernel: usb 1-2: New USB device found, idVendor=0781, idProduct=5581The options that do the work:
| Option | Effect |
|---|---|
-k | Kernel messages only |
-b, -b 0 | The current boot |
-b -1 | The previous boot |
-p err, -p err..warning | Priority or priority range |
-f | Follow new entries |
-n 50 | Last 50 entries |
--since "10 min ago", --until | Time range, with natural-language times |
-g PATTERN | Show entries matching a regular expression |
-o short-monotonic | Show the kernel's seconds-since-boot timestamps |
-o json | Machine-readable output |
-r | Newest first |
The previous boot is the reason many people reach for journalctl. After a crash and reboot, dmesg shows only the new boot, but a persistent journal still holds the lines from just before the crash:
journalctl -k -b -1 -p err --no-pager | tail -n 5Nov 22 22:01:50 host kernel: BUG: kernel NULL pointer dereference, address: 0000000000000008
Nov 22 22:01:50 host kernel: #PF: supervisor read access in kernel mode
Nov 22 22:01:50 host kernel: Oops: 0000 [#1] PREEMPT SMP NOPTI
Nov 22 22:01:50 host kernel: CPU: 2 UID: 0 PID: 4411 Comm: cat Tainted: G O 6.12.0 #1The last lines before a hard hang may not reach the journal, since the system died before journald could write them. For those, use a serial console or netconsole, covered in the netconsole post.
Searching by pattern and range together:
journalctl -k --since "09:00" --until "09:30" -g "usb 1-2" --no-pagerNov 23 09:25:10 host kernel: usb 1-2: new high-speed USB device number 8 using xhci_hcd
Nov 23 09:25:10 host kernel: usb 1-2: New USB device found, idVendor=0781, idProduct=5581Use -o short-monotonic when you need to compare a journal line with a timestamp in a kernel trace or an oops: it shows the same seconds-since-boot values that dmesg prints, so the two outputs line up.
Which one to use
| Situation | Use |
|---|---|
| Quick look at the current boot | dmesg |
| The error happened before the last reboot | journalctl -k -b -1 |
| Need accurate wall-clock times | journalctl -k |
| Following a hot-plug event | dmesg -wH |
| Scripting or filtering by a pattern | journalctl -k -g, or dmesg piped to grep |
| Embedded system with no systemd | dmesg |
| Need to match kernel traces by timestamp | dmesg or journalctl -o short-monotonic |
Permissions
By default, on many distributions any user can run dmesg. The sysctl kernel.dmesg_restrict set to 1 limits it to users with CAP_SYSLOG, since the log can reveal addresses and hardware details. If dmesg prints Operation not permitted or read kernel buffer failed, that is the setting at work. Use sudo, or add the user to the systemd-journal or adm group to read the journal without root. Reading /dev/kmsg directly has the same restriction. Also, journalctl -k shows only messages from your boot unless you have permission to read the system journal.
Reading a log for a failure
A practical order for a problem you do not understand:
Start from the end of the log:
dmesg | tail -n 50.Filter errors and warnings:
dmesg --level=err,warn.Search for the device or driver name, such as
grep -i nvmeorgrep ticker.For something that went wrong over time, look at the lines around the first error, not the last. The first failure usually causes the rest.
If the machine rebooted, read
journalctl -k -b -1for the end of the previous boot.If lines are missing, check whether the ring buffer wrapped: the first line should be the
Linux versionbanner at time 0. If it is not, the beginning was overwritten, and a largerlog_buf_len=boot parameter keeps more.


