Home » 2014 » November » 25 » DMESG command in Linux : to display or control kernel ring buffer

8:52 AM
DMESG command in Linux : to display or control kernel ring buffer

dmesg - To display or control the kernel ring buffer

Command syntax
       dmesg [ -c ] [ -n level ] [ -s bufsize ]

       dmesg is used to examine or control the kernel ring buffer. It display the status of device drivers loaded into kernel when the system boots up.

After boot up also, if a new hardware peripheral is connected dmesg displays the message about that peripheral.

The message could be error message like device not connected or a success message.

It is helpful in analysing and debugging any hardware related issue.

       The program helps users to print out their bootup messages.  Instead of copying the messages by hand, the user need only:  dmesg > boot.messages or boot.msg and mail the boot.messages file to whoever can debug their problem.

You can set the buffer size to query the kernel ring buffer

              Use  a  buffer of size bufsize to query the kernel ring buffer.  This is 16392 by default.  (The default kernel syslog buffer size was 4096 at first, 8192 since 1.3.54, 16384 since 2.1.113.) 

If you have  set  the  kernel  buffer  to  be larger than the default then this option can be used to view the entire buffer.

Lets try to understand dmesg with some examples

1.  Check bluetooth device drivers

[email protected]:/var/log:> dmesg|grep -i bluetooth
[email protected]:/var/log:>

2.To check memory status

[email protected]:/var/log:> dmesg|grep -i Memory
Memory: 8216172k/8396800k available (1961k kernel code, 171804k reserved, 825k data, 164k init)
Freeing initrd memory: 7552k freed
Non-volatile memory driver v1.2
Freeing unused kernel memory: 164k freed

3. To check ethernet drivers details, for example for first NIC eth0:

[email protected]:/var/log:> dmesg|grep -i eth0|more

FW portmap drop IN=eth0 OUT= MAC=00:16:3e:32:4c:5f:00:26:98:0a:a8:42:08:00 SRC= DST= LEN=60 TOS=0x00 PREC=0x00
TTL=63 ID=45210 DF PROTO=TCP SPT=37762 DPT=111 WINDOW=14600 RES=0x00 SYN URGP=0

4. To check the status of usb connected to system

[email protected]:/var/log:> dmesg|grep -i usb
[email protected]:/var/log:>

5. To check terminal type info

[email protected]:/var/log:> dmesg|grep -i tty
[email protected]:/var/log:>

If you want to clear dmesg log, you can use -c option. This will clear the log till the system boots up again.

But if you connect any other device after this, you can see the log of the hardware again in dmesg output.

[email protected]:/var/log:> dmesg -c
klogctl: Operation not permitted

You need to be root to clear dmesg log. Suppose you have delete the dmesg log, and still you want to see the log you can see in /var/log/boot.msg or /var/log/kern.og

[email protected]:/var/log:> ll boot.msg
-rw-r--r-- 1 root root 17572 2014-03-24 20:00 boot.msg



Category: Open System-Linux | Views: 1483 | Added by: shanky | Tags: dmesg, dmesg command with example, what is dmesg and how to use it?, dmesg command in linux, dmesg command in unix | Rating: 5.0/1

Related blogs

You may also like to see:

[2014-10-06][Open System-Linux]
Time command in Linux to give resource usage
[2014-12-28][Open System-Linux]
Shift command with examples
[2014-03-12][Open System-Linux]
uptime command in Linux
[2014-02-23][Open System-Linux]
lwp-download: A command in linux to downlaod large files from internet
[2014-10-17][Open System-Linux]
SETFACL command in Linux to set file access control list

Total comments: 0