🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

dmesg Command

Intermediate System Information man(1)

Print kernel ring buffer messages

👁 11 views 📅 Updated: Mar 15, 2026
SYNTAX
dmesg [OPTION]...

What Does dmesg Do?

dmesg displays the kernel ring buffer messages — the log of kernel events since boot. It contains hardware detection, driver loading, errors, warnings, and system events from the kernel.

dmesg is essential for troubleshooting hardware issues, driver problems, disk errors, network interface problems, and boot failures. It shows messages that are not visible in regular system logs.

On systemd systems, journalctl -k provides similar kernel message access with better filtering. But dmesg remains the universal tool available on all Linux systems.

Options & Flags

OptionDescriptionExample
-H Human-readable with pager dmesg -H
-T Show human-readable timestamps dmesg -T
-l Filter by log level dmesg -l err,warn
-w Follow — wait for new messages sudo dmesg -w
-c Clear the ring buffer after printing sudo dmesg -c
--color Colorize output dmesg --color=always | less -R
-f Filter by facility dmesg -f kern

Practical Examples

#1 View kernel messages

Shows the last 20 kernel messages with human-readable timestamps.
$ dmesg -T | tail -20

#2 Show errors and warnings

Filters to show only error and warning level messages.
$ dmesg -T -l err,warn

#3 Follow new messages

Continuously shows new kernel messages as they occur.
$ sudo dmesg -w

#4 USB device events

Shows recent USB device events (plug/unplug).
$ dmesg -T | grep -i usb | tail

#5 Disk errors

Searches for disk error messages in kernel log.
$ dmesg -T | grep -iE 'error|fail|bad|i/o' | tail

#6 Network interface events

Shows network interface state changes.
$ dmesg -T | grep -i 'eth\|link\|network'

Tips & Best Practices

Use -T for timestamps: dmesg without -T shows seconds since boot. -T converts to human-readable date/time.
Permission on newer kernels: Some kernels restrict dmesg to root. Use sudo dmesg or check dmesg_restrict: sysctl kernel.dmesg_restrict.
Ring buffer wraps: The kernel ring buffer has a fixed size. Old messages are overwritten. For persistent logs, use journalctl -k.

Frequently Asked Questions

How do I check for hardware errors?
Use dmesg -T -l err,warn to see kernel error and warning messages. Check for disk, memory, and driver errors.
How do I see USB device detection?
Plug in the device, then run dmesg -T | tail -20 to see the most recent kernel messages.
What is the difference between dmesg and /var/log/syslog?
dmesg shows kernel ring buffer (kernel messages only). syslog shows all system messages including services, daemons, and kernel.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →