dmesg
Display kernel messages
TLDR
Show kernel messages
Show kernel error messages
Show kernel messages and keep [w]aiting for new ones, similar to tail --follow (available in kernels 3.5.0 and newer)
Show how much physical memory is available on this system
Show kernel messages 1 page at a time
Show kernel messages with a timestamp (available in kernels 3.5.0 and newer)
Show kernel messages in human-readable form (available in kernels 3.5.0 and newer)
Colorize output (available in kernels 3.5.0 and newer)
SYNOPSIS
dmesg [options]
PARAMETERS
-C, --clear
Clear ring buffer after printing
-c, --read-clear
Read buffer and clear it
-D, --console-level LEVEL
Set console logging level
-d, --show-delta
Show delta timestamps
-E, --dissect
Dissect structured messages
-e, --reltime
Show relative timestamps
-F, --file FILE
Read from file instead of kernel buffer
-H, --human
Human-readable format
-h, --help
Display help
-K
Decode kernel facilities/priorities (alias for -x)
-k, --kernel
Kernel messages only
-L, --color[=WHEN]
Colorize output
-l, --level LEVEL_LIST
Filter by priority levels
-N, --live
Wait for new messages without blocking
-n, --console-level LEVEL
Set console log level
-P, --nopager
Disable pager
-p, --priority PREFIX
Prefix priority names
-r, --raw-priorities
Print raw priority values
-S, --since TIME
Messages since specified time
-s, --buffer-size SIZE
Set buffer size
-T, --ctime
Human-readable timestamps
-t, --notime
Omit timestamps
-u, --userspace
Userspace messages only
-U, --notruncate
Don't truncate lines
-V, --version
Show version
-w, --follow
Follow new messages (tail -f)
-x, --decode
Decode facilities and priorities
DESCRIPTION
dmesg is a powerful Linux command used to examine or control the kernel ring buffer, which stores boot-time and runtime kernel messages. These include hardware detection, driver initialization, device status, and error reports. The ring buffer is circular, so old messages are overwritten when full, making dmesg essential for troubleshooting boot issues, hardware problems, or kernel panics.
Without options, it prints the entire buffer in chronological order. Timestamps show boot-relative or wall-clock time. It's invaluable for debugging, as logs persist across reboots until cleared. Modern systems with systemd use journalctl, but dmesg remains key for raw kernel data.
Run as root for write operations like clearing or setting levels. Buffer size is configurable via /proc/sys/kernel/dmesg_restrict or boot params. Output can be filtered by level, time, or content, aiding analysis in large logs.
CAVEATS
Requires root or CAP_SYSLOG for clear/set operations; ring buffer overwrites old messages; restricted by /proc/sys/kernel/dmesg_restrict on some systems.
COMMON USAGE
dmesg | grep -i error for errors; dmesg -w to monitor live; dmesg -T for readable times.
BUFFER MANAGEMENT
Increase size with boot param dmesg=8M or echo 8M > /proc/sys/kernel/dmesg_restrict (requires root).
HISTORY
Originated in early Linux kernels (1990s) for accessing kernel log buffer; integrated into util-linux package around 2000; enhanced in util-linux 2.28+ with colors, deltas, dissection.
SEE ALSO
journalctl(1), syslogd(8), klogd(8)


