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 traceroute Command: Trace Routers on the Way to a Host

Linux traceroute Command: Trace Routers on the Way to a Host

Learn how to trace Routers on the Way to a Host with the Linux traceroute command, including practical examples, key options, and important precautions.

Linux Tutorial / File System Basics: Paths and Key Directories

Linux Tutorial / File System Basics: Paths and Key Directories

Understand the Linux directory tree, read absolute and relative paths, and learn what common directories such as /home, /etc, and /var are used for.

Linux split Command: Divide Large Files into Smaller Parts

Linux split Command: Divide Large Files into Smaller Parts

Learn how to divide Large Files into Smaller Parts with the Linux split command, including practical examples, key options, and important precautions.

Linux Tutorial / Manage Files and Directories: Create, Copy, Move, and Delete

Linux Tutorial / Manage Files and Directories: Create, Copy, Move, and Delete

Practice creating, copying, renaming, moving, and deleting files and directories in a dedicated folder while checking each result safely.

Linux sort Command: Sort Text Lines

Linux sort Command: Sort Text Lines

Learn how to sort text lines with the Linux sort command, including practical examples, key options, and important precautions.

Linux mkfs Command: Create a New Filesystem

Linux mkfs Command: Create a New Filesystem

Learn how to create a New Filesystem with the Linux mkfs command, including practical examples, key options, and important precautions.

Linux which Command: Find Executables in PATH

Linux which Command: Find Executables in PATH

Learn how Linux which searches PATH for executables, shows all matching paths, differs from type and command -v, and should be used carefully in scripts.

Linux screen Command: Create and Manage Detachable Terminal Sessions

Linux screen Command: Create and Manage Detachable Terminal Sessions

Learn how to use the Linux screen command to keep terminal sessions running and reconnect to them later, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux free Command: Check Memory and Swap Usage

Linux free Command: Check Memory and Swap Usage

Learn how to use the Linux free command to inspect available memory, used memory, cache, and swap usage, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux comm Command: Compare Two Sorted Files

Linux comm Command: Compare Two Sorted Files

Learn how to compare Two Sorted Files with the Linux comm command, including practical examples, key options, and important precautions.