Each operating system, including Linux, performs certain operations silently without informing the user. Although the user may not be aware of these actions, it may be necessary to check these actions to detect problems with the operating system and the devices connected to the computer system.

Fortunately, all these actions for the Linux operating system are stored in a circular buffer accessible with the diagnostic message (or dmesg) command. The dmesg command under Linux can be used to display all messages related to events that occur in your operating system. In this article you will learn how to use this useful command under Linux.

Pay attention: In this tutorial we used Linux Mint 20.

Use of controls

We will use several examples to explain how the command is used for diagnostic messages.

Example 1: Display all diagnostic messages

After performing these actions, you can display all types of diagnostic messages at the same time.

First click on the shortcut icon of the Linux Mint 20 terminal to start it.

The new terminal can be seen in the picture below:

Now all we have to do is execute the following command in the terminal:

When this command is executed, a long list of diagnostic messages appears on your device. You can scroll down to see all messages as shown in the figure below:

Example 2: Display diagnostic messages per page Page

In the previous example, the list of diagnostic messages was very long and not practical to read. So you can view these messages page by page, which you can do with the less command under Linux. In the command below we switch the output of the dmesg to a smaller command, so that the diagnostic messages are displayed page by page.

The result of the modified dmesg command is shown in the following figure.

After reading the first page you can press the space bar to go to the next page, and so on until the last page as indicated by the keyword END in the following figure:

Example 3: Displays diagnostic messages with a defined degree of severity

The severity of the diagnostic messages varies depending on the target. For example, some messages contain general information, while others contain warnings. You can display all diagnostic messages with a certain degree of severity as follows:

First execute the command dmesg -level=LEVEL in the Linux Mint 20 terminal. Here you must replace LEVEL with an actual level (e.g., error, warning, information, notification). Since we want to consider all diagnostic error messages in our example, we have replaced LEVEL with erroneous

This command returns all diagnostic messages with the error level shown in the following figure:

Example No 4: Display of the Linux version with the dmesg command

When we executed the dmesg command without other parameters, the output was too large to see immediately. Besides all other information, this issue also contained a version of your Linux system, but it was hard to find. If you want to see your version of Linux with the dmesg command, you can execute the following command in your terminal:

When you execute this command, the version of Linux on your terminal is displayed as shown in the figure below:

Example No 5: Time stamped display of diagnostic messages

The event takes place in the operating system at a certain time. For registration and auditing tasks, it is important to consult the timestamps of events that occur in your operating system to understand when a problem has occurred. To display temporary labels of diagnostic messages, you can execute the following command in the terminal:

The following screen shows the exact time, including day, date and time, for each diagnostic message.

Example No 6: Display device specific diagnostic messages

Diagnostic messages that are displayed only when the dmesg command is executed are not device-specific; instead, messages that apply to all devices are displayed at the same time. However, you may want to review the diagnostic messages for a specific device to identify problems that only relate to that device.

You can do this with the dmesg command by executing the dmesg | grep -i DEVICE command. Replace DEVICE with the name of the device whose diagnostic messages you want to display. In our case, we want to check the mouse’s diagnostic messages. That’s why we replaced him with the mouse.

When this command is executed, all diagnostic messages connected with the mouse are displayed on the terminal as shown in the following figure The diagnostic messages for each input/output device can be displayed in the same way.

Example No 7: Display of diagnostic messages and their severity

In example 3, we considered the diagnostic messages with some seriousness. However, if we want to display all diagnostic messages with their severity, we can execute the command dmesg -x. The -x flag can be used with the dmesg command to display diagnostic messages with their severity.

You can see in the following result that the severity of the diagnostic message is displayed at the beginning of the message.

Example No 8: Clear diagnostic message history

Thousands of events occur in the operating system that displays your operating system, and these events generate a long list of diagnostic messages, as shown in example 1. However, the Linux system also offers a way to clean up this protocol.

To delete the history of diagnostic messages, you can execute the sudo dmesg -C command. To clear the history of diagnostic alerts, which is important for auditing, run the sudo dmesg command. Otherwise, you will not be able to perform this operation. In addition, the -C flag, together with the dmesg command, is responsible for deleting the dmesg protocol.

After executing this command, nothing will appear on your terminal. So, to check if the history of the diagnostic messages has been erased, we’re going to run the dmesg command again. This time the dmesg command does not return diagnostic messages to your device because the history has been erased.


This tutorial introduces you to the diagnostic messages generated by the Linux operating system and shows you how to view timestamps of events that have occurred in the operating system, how to record all events of a particular severity, and how to view diagnostic messages for a particular device. The more advanced versions of the dmesg available in this article can be obtained for different results.

kernel ring buffer,linux dmesg timestamp,dmesg –level,dmesg -n 7,dmesg command mcq,dmesg out of memory,dmesg linux command,dmesg vs journalctl,dmesg 1 general commands,dmesg mac,modprobe list modules,modprobe grep,how to open ko file in ubuntu,bash netstat,modprobe load module,debian install modprobe,linux dmesg log,dmesg options,dmesg command is used for,dmesg command shows,dmesg linux path,linux old dmesg

You May Also Like

Linux Stat Command and its Usage

The stat command is used on a Linux/Unix system to display detailed…

Try something that can’t be SIM swapped • The Register

On Tuesday, Microsoft Corporation advised Internet users to accept multi-factor authentication (AMF)…

How To Effectively Market Your Business On Instagram

Storytelling is one of the most effective methods to promote your business…

What Happens If I Open The Dishwasher Mid-Cycle?

You’ve been cycling for 15 minutes. Then it will happen. Forgotten coffee…