Linux dmesg Command: Read Kernel and Boot Messages

dmesg reads messages recorded in the kernel ring buffer. It helps investigate hardware detection, drivers, filesystems, and kernel warnings during boot.

What is the dmesg command?

The kernel ring buffer has a limited size, so older messages can be overwritten. The default output includes messages of different priorities and timestamps. Human-readable timestamps from -T can be inaccurate if the system clock has been adjusted; consult the journal's boot log when timing matters.

Basic syntax

dmesg [option]

Implementations and options may vary by distribution. Check your system's documentation with man dmesg.

Examples

Checking kernel messages

It outputs up to the most recent records, so if the screen is long, use a pager.

dmesg | less

Viewing only warnings and errors

Reduces the scope of investigation to error and warning levels.

dmesg --level=err,warn

Follow new messages

Check incoming kernel messages in real time. Press Ctrl+C to stop.

dmesg --follow

Reading Kernel Messages and Relative Time

The default time display of dmesg is usually based on the elapsed time since boot. After the number, messages related to hardware, drivers, or the filesystem follow.

dmesg --level=err,warn | tail -n 3

Example format (actual messages vary by system):

[   12.345678] device: warning message

If the output is empty, there may be no messages of that level in the current ring buffer, and if you cannot read it due to permission restrictions, an error will be displayed. Since the size of the ring buffer is limited and old records may disappear, check the journal retention along with previous boot events using journalctl -k -b -1. dmesg -c clears the buffer, so it is not used for simple checks.

Main Options and Format

Options/Format Description
--level=LIST Displays only messages of the specified priorities.
-T Displays time in a human-readable format.
-H Uses human-readable output and a pager.
-w Continuously waits for new messages.
-k Displays kernel messages only.

Precautions when using

Some distributions restrict non-administrators from reading the kernel log; check the system policy if you encounter a permission error. dmesg -c and --clear clear the buffer, so do not use them for a simple query. An empty result does not prove there is no problem. If retained by the journal, you can inspect the previous boot's kernel messages with journalctl -k -b -1.

Frequently Asked Questions

dmesg and journalctl -k, are they the same?

Both allow you to check kernel messages, but dmesg reads the kernel ring buffer, whereas journalctl -k queries the kernel entries collected and stored in the journal.

Official Documentation

For exact option behavior, see the dmesg manual page.

More in This Category
Linux gunzip Command: Decompress gzip Files

Linux gunzip Command: Decompress gzip Files

Learn how to decompress gzip Files with the Linux gunzip command, including practical examples, key options, and important precautions.

Linux lscpu Command: Inspect CPU Architecture and Cores

Linux lscpu Command: Inspect CPU Architecture and Cores

Learn how to inspect CPU Architecture and Cores with the Linux lscpu command, including practical examples, key options, and important precautions.

Linux cp Command: Copy Files and Directories

Linux cp Command: Copy Files and Directories

Learn how to copy files and directories with Linux cp, control overwrites, preserve attributes, handle symlinks, and verify important copies.

Linux readlink Command: Inspect Symbolic Link Targets

Linux readlink Command: Inspect Symbolic Link Targets

Learn how to use the Linux readlink command to display symbolic link targets and optionally resolve canonical paths, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux chgrp Command: Change a File's Group

Linux chgrp Command: Change a File's Group

Learn how to change a File's Group with the Linux chgrp command, including practical examples, key options, and important precautions.

Linux ln Command: Create Hard Links and Symbolic Links

Linux ln Command: Create Hard Links and Symbolic Links

Learn how to create hard links and symbolic links with Linux ln, choose relative or absolute targets, replace links safely, and inspect link behavior.

Linux Tutorial / Understand systemd Services, Boot, and Logs

Linux Tutorial / Understand systemd Services, Boot, and Logs

Understand Linux boot stages and systemd units, distinguish active services from boot enablement, and inspect current-boot logs with systemctl and journalctl.

Linux tree Command: Display a Directory Tree

Linux tree Command: Display a Directory Tree

Learn how to use the Linux tree command to display directory contents as a readable hierarchy and control depth and filtering, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux rm Command: Remove Files and Directories Safely

Linux rm Command: Remove Files and Directories Safely

Learn how to remove files and directory trees with Linux rm, use interactive safeguards, limit recursive deletion, and avoid destructive path mistakes.

Linux w Command: Show Logged-In Users and Their Processes

Linux w Command: Show Logged-In Users and Their Processes

Learn how to show Logged-In Users and Their Processes with the Linux w command, including practical examples, key options, and important precautions.