Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Read Kernel Messages with the dmesg Command

dmesg shows what the Linux kernel reports about hardware, drivers and errors.

VPS and Cloud Servers2 min read13 screenshots

What dmesg is

dmesg prints the messages in the kernel ring buffer. These messages come from the boot process, drivers and hardware. They are the first place to look for disk errors, USB problems or out-of-memory kills.

dmesg [options]
OptionMeaning
-CClear the buffer
-cPrint and then clear the buffer
-HHuman-readable output
-THuman-readable time stamps
-lFilter by log level (for example err, warn)
-kShow only kernel messages
-sSet the size of the buffer to read
-fFilter by facility
-rRaw output
-xShow facility and level as text

Read the manual with:

man dmesg
The dmesg manual page

Examples

Show all messages

sudo dmesg
Output of dmesg

Page by page. The output is long. Pipe it to less:

sudo dmesg | less
dmesg with less

Use the arrow keys to scroll and q to quit.

Colors

sudo dmesg -L
Colored dmesg output

Turn colors off:

sudo dmesg --color=never
dmesg without colors

Easier time format. Kernel time stamps are seconds since boot. Use -H for a friendlier format:

sudo dmesg -H
dmesg with -H

Real date and time

sudo dmesg -T
dmesg with -T

First or last lines

sudo dmesg | head
sudo dmesg | tail
The first lines of dmesg
The last lines of dmesg

Only errors and warnings

sudo dmesg -l err,warn
dmesg filtered by level

Search for a word

sudo dmesg | grep -i usb
dmesg with grep

Level and facility as text

sudo dmesg -x
dmesg with -x

The saved boot log. On many systems, the messages from the last boot are also saved in a file:

less /var/log/dmesg
Reading the dmesg log file
Tip: On newer systems, sudo journalctl -k shows kernel messages with history across reboots.

Quick recap

  • dmesg shows kernel and hardware messages.
  • Use -T for dates and -l err,warn for problems.
  • Pipe to less or grep to make the output easier to read.