Monitoring and diagnostics

Command dmesg

Show kernel messages

Linux · Bash examples · commands run on the selected server

When to use dmesg

Use dmesg to inspect the kernel's message buffer while investigating device, driver and storage events. Access may be restricted, and the buffer is not an unlimited history of everything that happened since installation.

Syntax

dmesg [PARAMETERS]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-H
Human-readable view of messages in util-linux.
-w
Watch for new kernel messages.
--level=LIST
Filter by importance level.

Usage examples

View recent kernel messages

sudo dmesg | tail -n 50

A short tail of kernel messages is displayed.

Select errors and warnings

sudo dmesg --level=err,warn

Only warning and error priority messages are requested.

Follow new events

sudo dmesg -w

New kernel messages are followed until you interrupt the viewer.

Notes and limitations

  • Access is often controlled by the kernel.dmesg_restrict setting.
  • The kernel ring buffer is not a complete long-term log. Messages may be suppressed.

Common questions and troubleshooting

Why does dmesg report an access error?

Kernel log visibility may be restricted by system policy. Use authorised access or the permitted journal interface rather than disabling protections.

Are dmesg timestamps always wall-clock time?

Not necessarily. Output can use time since boot and conversion modes have limitations. Correlate with boot time and journal timestamps carefully.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man dmesg.