Thursday, 22 August 2013

A short tutorial on dmesg, Linux command !

The command is "dmesg" which means "display messages" or "driver messages" as per Wiki, but I think it should be "debug messages" as these messages helps the developers to debug the Linux Kernel problem occurred during boot-up time or later. These messages are mostly hardware related messages, in which the peripherals or the actual ports gets initialized. If we give this command without any option it will print all messages on screen.

The format of command:

Usage: dmesg [-c] [-n level] [-s bufsize]
The man file says:

[root@localhost ~]# man dmesg
Formatting page, please wait...
       The program helps users to print out their bootup messages.  Instead of
       copying the messages by hand, the user need only:
              dmesg > boot.messages
       and mail the boot.messages file to whoever can debug their problem.
OPTIONS
       -c     Clear the ring buffer contents after printing.
       -r     Print the raw message buffer, i.e., donĂ¢t strip  the  log  level
              prefixes.
       -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.
       -nlevel
              Set  the  level at which logging of messages is done to the con-
              sole.  For example, -n 1 prevents  all  messages,  expect  panic
              messages, from appearing on the console.  All levels of messages
              are still written to /proc/kmsg, so syslogd(8) can still be used
              to  control  exactly  where kernel messages appear.  When the -n
              option is used, dmesg will not print or clear  the  kernel  ring
              buffer.
              When  both options are used, only the last option on the command
              line will have an effect.
SEE ALSO
       syslogd(8)
AVAILABILITY
       The dmesg command is part of the util-linux-ng package and is available
       from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
                                                     
The commands which can be used are:

1) dmesg -> display whole output on screen

2) dmesg | less  -> display output as one screen at a time

3) dmesg > debug.log -> redirect all messages to log file

4) dmesg | grep usb/time/interrupt/tty/dma/memory -> to display(grep) only relevant or required information

5) dmesg -n 1 -> stop all messages except panic messages

I could not find information on various levels , let me know if any one of you know.

Heppy Learning, Happy Sharing!

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...