System and processes
The dmesg command
Shows the kernel log since boot: hardware, disks, network and errors.
Most useful options
-T, --ctimePrints a readable time instead of seconds since boot-H, --humanOutput meant for reading. Enables the pager by default-l, --level nivelesFilters by level: err, warn, crit... With err+ it also includes the more severe ones-k, --kernelShows only the kernel messages-t, --notimeRemoves the kernel timestamps-c, --read-clearShows the log and then empties it. This cannot be undoneCopy-ready examples
$ dmesg | tail -n 20the latest messages the kernel has logged.$ dmesg | grep -i usblooks for clues about a USB device that does not work.$ dmesg --level=err,warnonly errors and warnings.$ dmesg --level=err+errors and everything more severe than them.$ sudo dmesg -T | tail -n 5the last five lines with readable dates, using sudo if the system restricts reading.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| dmesg: read kernel buffer failed: Operation not permitted | The kernel restricts reading the log to unprivileged users, according to the dmesg_restrict setting. | Run it with sudo: sudo dmesg. |
| dmesg: invalid time value "algo" | The --since value is understood neither as a date nor as a relative time. | Use a date or a relative time in quotes: dmesg --since '1 hour ago'. |
| dmesg: bad usage | You typed a loose argument that dmesg does not accept, often a text with no option in front. | To filter text use a pipe: dmesg | grep text. |
Typical mistakes
- Kernel messages are in English: search for words such as error, failed or usb.
- The buffer has a fixed size: the oldest messages are overwritten and no longer appear.
- If a USB or a disk does not work, the clue usually appears when you plug it in.
Differences from similar commands
- journalctl: reads the systemd journal, which includes kernel messages. dmesg reads only the kernel buffer.
- systemctl: controls services. It does not show kernel messages, so for a hardware fault look at dmesg.
- uptime: tells how long the system has been up. dmesg marks each line with the seconds elapsed since boot.
Related commands
FAQ
What does the number in brackets mean?
The seconds elapsed since the system booted, with decimals. With -T you see a readable time instead.
Why won't dmesg let me read the log?
The kernel may restrict it to unprivileged users (dmesg_restrict). Using sudo usually works.
How do I see messages from a previous boot?
dmesg only shows the current boot. For an earlier one try journalctl -k -b -1, if the journal keeps records across boots.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course