Friday, January 15, 2010

dmesg Command in Linux

This article serves as an introduction , to one of the rarely known UNIX commands to general under-graduate students , the "dmesg" command .


Definition :
dmesg - print or control the kernel ring buffer  .


What do we mean by the term Kernel Ring Buffer ?


In simplest terms it is a log which contains messages from the kernel .


For example we can try a simple command :


[root@localhost]#dmesg | grep Memory 
[    0.000000] Memory: 371348k/393152k available (4565k kernel code, 21120k reserved, 2143k data, 540k init, 0k highmem) 


This command gives certain information about the memory reserved by the kernel at boot time .


Uses of dmesg command:


1) Useful to extract information , about the functioning of various kernel modules basically the device drivers.


Therefore , this message was  logged in by the kernel at the time of file system mounting and can be extracted using the dmesg utility .


Useful Links :
1 ) http://ftp-uxsup.csx.cam.ac.uk/pub/doc/suse/suse9.2/suselinux-adminguide_en/ch29s09.html 
Offers a simple and an effective example .



2) For more advanced usage of dmesg command refer :
http://www.linfo.org/dmesg.html
 The link mentioned , also provides the answer to the general query of what is a Ring Buffer.




 For those interested to see the file from which we can see the input file to the dmesg command ,
open the file /var/log/dmesg with any standard text editor.




Hope this solves some of your queries.




No comments: