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 ]

DESCRIPTION
       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

 -sbufsize
              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

shanky@localhost:/var/log:> dmesg|grep -i bluetooth
shanky@localhost:/var/log:>

2.To check memory status

shanky@localhost:/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:

shanky@localhost:/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=160.50.74.168 DST=160.50.76.95 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

shanky@localhost:/var/log:> dmesg|grep -i usb
shanky@localhost:/var/log:>

5. To check terminal type info

shanky@localhost:/var/log:> dmesg|grep -i tty
shanky@localhost:/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.

shanky@localhost:/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


shanky@localhost:/var/log:> ll boot.msg
-rw-r--r-- 1 root root 17572 2014-03-24 20:00 boot.msg

 

 
 

Category: Open System-Linux | Views: 1882 | 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:


[2016-12-25][Open System-Linux]
Guide for working with zipped and archived files in Linux/AIX
[2014-11-19][Open System-Linux]
ETHTOOL : A tool in Linux to display or change ethernet card setting
[2014-12-22][Open System-Linux]
Key mapping inside VI editor
[2014-02-23][Open System-Linux]
lwp-download: A command in linux to downlaod large files from internet
[2014-03-17][Open System-Linux]
AWK command for scanning and analysing a large file in Linux

Total comments: 0
ComForm">
avatar