dmesg on Linux: Read Kernel Logs (Hardware, OOM, USB, Disk Errors)

dmesg linux - custom-dmesg-featured.png

dmesg on Linux surfaces what the kernel saw: new disks, link up/down, driver failures, and the infamous Out of memory: Killed process line. It complements application logs when the problem is below userspace.

See also: journalctl,
OOM fixes,
free & memory.

Kernel Ring Buffer

dmesg prints messages since boot (subject to buffer size and sysctl restrictions).

bashreadable time
sudo dmesg -T | tail -30
dmesg -T
-w follow

Hardware Events

Plug a USB drive or NIC cable — dmesg often shows detection before lsblk updates.

USB
link up

Boot vs Runtime

First lines are early boot; for persistent kernel logs use the journal.

bashjournal kernel
sudo journalctl -k -b --no-pager | tail -40
journalctl -k
boot

Hunt Errors

Filter for error, fail, I/O error, and OOM strings when a box becomes slow or services vanish.

bashoom
sudo dmesg -T | grep -iE 'out of memory|oom|killed process' | tail -10
OOM
I/O error

Clearing dmesg

dmesg -C clears the ring buffer — only when you know you do not need those messages.

WarningPrefer journaling (journalctl -k) for audits — clearing dmesg removes evidence of transient hardware faults.
dmesg -C
careful

Permissions

Some distros restrict dmesg for unprivileged users via kernel.dmesg_restrict.

sudo
sysctl

Verify After a Change

Trigger the event (cable, mount, module load) and tail dmesg immediately.

bashfollow
sudo dmesg -w
tail -f
reproduce

Quick Reference

  • Readable times: dmesg -T
  • OOM clues: dmesg | grep -i oom
  • Persistent: journalctl -k

Related tutorials

Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.