dmesg – Display Linux system boot information

The dmesg command is a Linux utility that displays kernel ring buffer messages. It is used to view the messages produced by the kernel during the boot process and after the system has started. The messages can be used to diagnose hardware and software problems, as well as to monitor system activity.

Overview

The dmesg command is a simple tool that displays kernel ring buffer messages. When the system boots up, the kernel initializes and starts logging messages to a circular buffer in memory. This buffer is known as the kernel ring buffer. The dmesg command reads the contents of this buffer and displays them to the user.

The dmesg command can be used to display a variety of information about the system, including hardware events, driver messages, and system errors. It can also be used to monitor system activity in real-time by using the -w option.

Here are some examples of how to use the dmesg command:

  • Display the last 20 kernel messages: dmesg | tail -n 20
  • Display kernel messages in real-time: dmesg -w
  • Display kernel messages related to a specific driver: dmesg | grep driver_name

Options

The dmesg command has several options that can be used to customize its behavior. Here is a table of the available options:

Option Description
-c Clear the kernel ring buffer after displaying its contents
-s SIZE Set the size of the kernel ring buffer to SIZE kilobytes
-T Print timestamps in human-readable format
-d LEVEL Set the level of kernel messages to display (default is all)
-w Wait for new kernel messages and display them in real-time

Troubleshooting tips

If the dmesg command does not display any output, it may be because the kernel ring buffer has been cleared. This can happen if the system has been rebooted or if the dmesg -c command has been run. To view the latest kernel messages, run the dmesg command without any options.

If the dmesg command displays an error message, it may be because the user does not have sufficient privileges to access the kernel ring buffer. In this case, the command should be run with root privileges using the sudo command.

Notes

  • The dmesg command is a useful tool for diagnosing hardware and software problems on a Linux system.
  • The kernel ring buffer is a circular buffer in memory that stores kernel messages.
  • The dmesg command can display a variety of information about the system, including hardware events, driver messages, and system errors.
  • The dmesg command has several options that can be used to customize its behavior, including the ability to clear the kernel ring buffer, set its size, and filter messages by level.
  • If the dmesg command does not display any output, it may be because the kernel ring buffer has been cleared or the user does not have sufficient privileges to access it.