≡ Menu

Troubleshooting Using dmesg Command in Unix and Linux

During system bootup process, kernel gets loaded into the memory and it controls the entire system.

When the system boots up, it prints number of messages on the screen that displays information about the hardware devices that the kernel detects during boot process.

These messages are available in kernel ring buffer and whenever the new message comes the old message gets overwritten. You could see all those messages after the system bootup using the dmesg command.

1. View the Boot Messages

By executing the dmesg command, you can view the hardwares that are detected during bootup process and it’s configuration details. There are lot of useful information displayed in dmesg. Just browse through them line by line and try to understand what it means. Once you have an idea of the kind of messages it displays, you might find it helpful for troubleshooting, when you encounter an issue.

# dmesg | more
Bluetooth: L2CAP ver 2.8
eth0: no IPv6 routers present
bnx2: eth0 NIC Copper Link is Down
usb 1-5.2: USB disconnect, address 5
bnx2: eth0 NIC Copper Link is Up, 100 Mbps full duplex

As we discussed earlier, you can also view hardware information using dmidecode.

2. View Available System Memory

You can also view the available memory from the dmesg messages as shown below.

# dmesg | grep Memory
Memory: 57703772k/60817408k available (2011k kernel code, 1004928k reserved, 915k data, 208k init)

3. View Ethernet Link Status (UP/DOWN)

In the example below, dmesg indicates that the eth0 link is in active state during the boot itself.

# dmesg  | grep eth
eth0: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem 96000000, IRQ 169, node addr e4:1f:13:62:ff:58
eth1: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem 98000000, IRQ 114, node addr e4:1f:13:62:ff:5a
eth0: Link up

4. Change the dmesg Buffer Size in /boot/config- file

Linux allows to you change the default size of the dmesg buffer. The CONFIG_LOG_BUF_SHIFT parameter in the /boot/config-2.6.18-194.el5 file (or similar file on your system) can be changed to modify the dmesg buffer.

The below value is in the power of 2. So, the buffer size in this example would be 262144 bytes. You can modify the buffer size based on your need (SUSE / REDHAT).

#  grep CONFIG_LOG_BUF_SHIFT  /boot/config-`uname -r`
CONFIG_LOG_BUF_SHIFT=18

5. Clear Messages in dmesg Buffer

Sometimes you might want to clear the dmesg messages before your next reboot. You can clear the dmesg buffer as shown below.

# dmesg -c

# dmesg 

6. dmesg timestamp: Date and Time of Each Boot Message in dmesg

By default the dmesg don’t have the timestamp associated with them. However Linux provides a way to see the date and time for each boot messages in dmesg in the /var/log/kern.log file as shown below.

klogd service should be enabled and configured properly to log the messages in /var/log/kern.log file.

# dmesg | grep "L2 cache" 
[    0.014681] CPU: L2 cache: 2048K

# grep "L2 cache" kern.log.1
Oct 18 23:55:40 ubuntu kernel: [    0.014681] CPU: L2 cache: 2048K
Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • Man from Mars October 26, 2010, 7:43 am

    Very nice and clear, as usual!
    Dmesg has always proven to me to be the first diagnostic tool for any Linux O.s.
    There are so many ways one can easily inspect and repair a system through CLI utils. That’s why I came to love so much GNU / Linux: despite the problems that may occur, there is always the right tool ready to use.

  • Anonymous October 26, 2010, 12:12 pm

    >> Linux allows to you change the default size of the dmesg buffer.
    >> The CONFIG_LOG_BUF_SHIFT parameter in the
    >> /boot/config-2.6.18-194.el5 file (or similar file on your system)
    >> can be changed to modify the dmesg buffer.

    Not recommended, unless you are intending to recompile the kernel. Just changing the value in this file does not change dmesg alone. The config file is only used when recompiling the kernel, unless I am missing something.

    Every time the stock Distro kernel is updated or replaced, such as with apt-get, aptitude, or synaptic such as in Debian, the Distro I use, that line/number may get replaced.

    From my Debian “/boot/config-2.6.32-5-amd64”:

    “#
    # Automatically generated make config: don’t edit
    # Linux kernel version: 2.6.32
    # Tue Oct 19 23:25:26 2010
    #”

  • Rick Stanley October 26, 2010, 12:13 pm

    >> Linux allows to you change the default size of the dmesg buffer.
    >> The CONFIG_LOG_BUF_SHIFT parameter in the
    >> /boot/config-2.6.18-194.el5 file (or similar file on your system)
    >> can be changed to modify the dmesg buffer.

    Not recommended, unless you are intending to recompile the kernel. Just changing the value in this file does not change dmesg alone. The config file is only used when recompiling the kernel, unless I am missing something.

    Every time the stock Distro kernel is updated or replaced, such as with apt-get, aptitude, or synaptic such as in Debian, the Distro I use, that line/number may get replaced.

    From my Debian “/boot/config-2.6.32-5-amd64”:

    “#
    # Automatically generated make config: don’t edit
    # Linux kernel version: 2.6.32
    # Tue Oct 19 23:25:26 2010
    #”

  • bob April 2, 2012, 7:32 am

    might want to specify that “dmesg” means “daemon message” so that people can recall the command easily later on.

  • benjamin July 16, 2013, 3:41 am

    As Rick said, I think the kernel config file just shows the configuration selected before compiling the kernel.

  • satyabrata pani January 17, 2017, 1:29 am

    “Kernel”, “Kernel Module” and “Kernel Parameter”, can you please explain on those. Are all means same or different? Please give some idea.