The Linux command dmesg It is a very popular tool that we have already talked about before in LxA. Thanks to it, messages can be retrieved and displayed from the Linux kernel ring buffer. These messages are very interesting, since they provide a lot of information about the equipment, both at the hardware and system level.
All this information can be valuable (boot, memory, CPU, devices, modules, ...) when it comes to detect problems and fix them. Therefore, you should know some practical commands that are essential to check if there is a problem on your machine and that will give you clues on how to tackle it.
In order to obtain this information, you can use the following commands:
- To list all drivers loaded in Linux kernel you can use the following command:
<br data-mce-bogus="1"> dmesg | less<br data-mce-bogus="1">
- List all detected devices Let them be called "name" (substitute name for whatever you need, such as sda, gpu, usb, dma, memory ...):
dmesg | grep -i nombre
- View error messages that can indicate the problems that exist in the system (you can also look for other levels of warnings, such as info, warning, etc.):
dmesg | grep -i error
- Monitor the kernel ring buffer in real time, to see what is happening now (you can try to do some actions in the system to see that new messages appear, for example connect and disconnect a USB memory):
watch "dmesg | tail -20"
- You can also delete the record of the ring buffer to make it clean. For this you can use the following command:
If you are interested in seeing the logs or records of the ring buffer, you should know that they are stored in / var / log / dmesg. And remember that this file will exist even if you are using systemd in your distro, just like it is in Sys V init and the like. In fact, it is also in plain text, so you can use the concatenator (cat) to display it ...