What it does
The kernel writes its messages into a ring buffer in memory. dmesg prints it: from the first boot messages to new events, like a USB stick being plugged in or a disk error. Times are seconds since boot; -T makes them readable.
On RHEL, normal users may be blocked (kernel.dmesg_restrict = 1); root can always read it. journalctl -k shows the same messages and also those of earlier boots.
How to write it
dmesg [OPTION]...Options 30
Most used
Filter
Time and format
Buffer
Console
Nothing matches this filter.
Examples 11
$ run as a normal user# run as root (or with sudo)
1All kernel messages
dmesg | lessFrom the boot until now.
2Readable times
dmesg -T | tail [Sun Oct 25 10:31:07 2026] sd 2:0:0:0: [sdc] Attached SCSI removable diskWhen did it happen?
3Errors and warnings only
dmesg -T --level=err,warnFirst check for hardware trouble.
4Watch live
dmesg -wTPlug in a device and see the messages.
5Disk errors (I/O)
dmesg -T | grep -iE 'i/o error|blk_update_request|ata[0-9].*error'A failing disk or cable.
6Memory killer
dmesg -T | grep -i 'out of memory'Which process the OOM killer killed.
7Find the device name of a new USB disk
Then use lsblk.
8Firewall drops logged by the kernel (security)
dmesg -T | grep -i 'filter_'Shows packets that were logged and dropped.
9Segfaults of programs
dmesg -T | grep -i segfaultCrashes and possible exploit attempts.
10Check if users may read it (hardening)
sysctl kernel.dmesg_restrict kernel.dmesg_restrict = 11 = only root (hides kernel addresses from attackers).
11Earlier boots
journalctl -k -b -1dmesg only shows the current boot.
Nothing matches this filter.
Exit codes
0 :: Done. 1 :: Error.