Use dmseg to check the kernel message buffers on Linux systems

NS dmesg The command displays the contents of the kernel’s message buffer since the latest boot of the system. You’ll see a lot of details about how your system is working and what you might be having problems that you wouldn’t normally see. This can be a lot of data, but there are some tricks to reduce it.

For example, the system queried below has been running for just over three days, but has collected over 1,000 rows of data.

$ dmesg | wc -l

Only when entering dmesg, All available data will be displayed. No sudo access required.You can also pipe the output of dmesg NS more When Less than A command to scan it or just pipe the output grepHowever, the command itself offers many options for selecting the most relevant information from the file.

$ dmesg | grep NIC
[   21.483886] e1000e 0000:00:19.0 enp0s25: NIC Link is Up 100 Mbps Full Duplex, Flow Control: Rx/Tx
[   27.504178] e1000e 0000:00:19.0 enp0s25: NIC Link is Down

One of the things you notice when you first start watching dmesg The output is the number on the left side of every line. These are the dates / times expressed in seconds and nanoseconds since the last boot. They look like this:

[   12.469099]

The first date display above means that the data was recorded about 12 and a half seconds after the system was last booted. In a calculation like the one below, you can see that the second date displayed is more than 3 days old. The number 86400 is the number of seconds in a day.

$ echo "scale=2; 274011 / 86400" | bc

An easy way to display a date / time field is -NS Also -NS Options to convert these fields to dates and times as we are familiar with.

Copyright © 2021 IDG Communications, Inc. Use dmseg to check the kernel message buffers on Linux systems

Back to top button