How-to

The dmesg Command: Read Kernel Messages on Linux

dmesg prints the kernel ring buffer: hardware detection at boot, driver warnings, disk errors and out of memory kills. It is the first place to look when hardware or the kernel misbehaves.

What is in the kernel ring buffer?

The kernel keeps a fixed size buffer of its own messages. At boot it fills with CPU, memory, PCIe, storage and network detection lines. After that it records driver events, link changes, filesystem errors, segfaults in user programs and the out of memory killer. When the buffer fills, the oldest lines drop out, but systemd also stores them in the journal, so journalctl -k shows the same messages with history across boots.

How do I read dmesg with real timestamps?

sudo dmesg -T | less
sudo dmesg --ctime --level=err,warn
sudo dmesg -H

By default dmesg prints seconds since boot, which is hard to match with other logs. -T or --ctime converts to wall clock time. It can drift slightly after a suspend, which servers rarely do. -H gives a paged, colored, human view. On many distros reading dmesg needs root because kernel.dmesg_restrict is set to 1.

How do I filter by severity or source?

sudo dmesg -l emerg,alert,crit,err
sudo dmesg -f kern -l warn
sudo dmesg --facility=daemon -x

-l picks levels from emerg down to debug, and -f picks facilities. -x adds the facility and level as a prefix to each line so you can see what you are filtering on. For one boot session after a crash, use journalctl -k -b -1 -p err instead, since dmesg only knows the current boot.

How do I follow kernel messages live?

sudo dmesg -wT
sudo journalctl -kf

-w waits for new messages, which is handy while you plug in a USB key on a desk machine and, more usefully on a server, while you load a module, reset a NIC or run a disk test. Stop with Ctrl+C.

What common problems does dmesg reveal?

PatternWhat it means
Out of memory: Killed process 3311 (java)RAM ran out and the kernel killed the biggest process
nvme0: I/O timeout, blk_update_request: I/O errorStorage errors; check the drive at once
EXT4-fs error, XFS ... metadata corruptionFilesystem damage; plan an fsck
Link is Down, Link is Up 25000 MbpsNetwork port state and negotiated speed
mce: [Hardware Error]Machine check: CPU or memory reported an error
segfault at ... error 4 in libc.soA user program crashed
task ... blocked for more than 120 secondsA process stuck on I/O for two minutes
sudo dmesg -T | grep -iE 'oom|killed process'
sudo dmesg -T | grep -iE 'nvme|ata[0-9]' | grep -iE 'err|fail|timeout'

How do I check hardware detection at boot?

sudo dmesg | grep -iE 'smpboot|Memory:'
sudo dmesg | grep -i 'nvme.*pci'
sudo dmesg | grep -iE 'eth|ens|enp' | grep -i link

These show how many CPUs came online, how much memory the kernel sees, which NVMe drives were found and at what link width, and the speed each network port negotiated. On a 25 Gbps model like D1, the link lines should report 25000 Mbps; anything lower points at a negotiation problem worth a ticket. lscpu command gives a cleaner CPU summary once the system is up.

Can I clear dmesg?

sudo dmesg -c > /root/dmesg-before-test.txt
sudo dmesg -C

-c prints then clears, -C just clears. Clearing before a test makes it easy to see only the new lines afterwards. The journal still keeps everything, so nothing is truly lost.

What if I find hardware errors?

Save the output to a file, note the time and open a ticket from the panel with the lines attached. For storage errors, also run Check disk health with smartctl and make sure your latest backup is good. A single corrected memory error is not an emergency; a stream of them, or any uncorrected one, is. For memory pressure kills rather than hardware faults, see Check memory usage and give the process a limit or move to a model with more RAM.

Which dmesg lines are harmless noise?

Plenty of boot lines look alarming but mean nothing. ACPI warnings about firmware tables, messages that a feature is not supported by the BIOS, and notices about unused PCIe slots are normal on server boards. So are audit messages from AppArmor or SELinux denying something you never use. Focus on lines that repeat after boot, mention your drives or network ports by name, or carry the err level or higher.

Machines and Their Port Speeds

ServerProcessorCores / threadsMemoryStorageNetworkPer monthSmallest order
S1Intel Xeon E-2276G6 / 1264 GB DDR41x 1 TB NVMe2x 10 Gbps$53.32$53.32 (1 month)
D12x Intel Xeon Gold 5315Y16 / 32128 GB DDR42x 1 TB NVMe2x 25 Gbps$202.94$202.94 (1 month)
X1Intel Xeon 6527P24 / 48256 GB DDR52x 4 TB NVMe2x 25 Gbps$522.51$522.51 (1 month)

Keep Reading

Read Linux log files

Find and read Linux logs on a server: the systemd journal, /var/log text files, app logs, filtering by time and following live output.

Open

Check disk health with smartctl

Read SMART and NVMe health data with smartctl, run self tests, and spot a drive that is wearing out before it takes your data with it.

Open

lscpu command

Read your server CPU details with lscpu: model, sockets, cores, threads, NUMA nodes, caches, flags and clock speeds, and what each one means.

Open

Check memory usage

Read free, /proc/meminfo, vmstat and per-process numbers correctly, and tell real memory pressure apart from a healthy page cache.

Open

FAQ

Quick Answers

kernel.dmesg_restrict is set to 1, which limits it to root. Use sudo.

dmesg only has the current boot. Use journalctl -k -b -1 for the previous one.

Seconds since boot. Add -T to show the wall clock time instead.

Run sudo dmesg -T | grep -i killed process, or journalctl -k | grep -i oom.

kern.log is a text copy written by rsyslog on Debian and Ubuntu. dmesg reads the kernel buffer directly.