The dmesg Command
The dmesg command is used to write the kernel messages in Pisi Linux and other Linux or Unix-like operating systems to standard output (which by default is the display screen).
dmesg can be very useful when troubleshooting or just trying to obtain information about the hardware on a system.
As Example here an Image of the output dmesg
Invoking dmesg without any of its options (which are rarely used) causes it to write all the kernel messages to standard output.
This usually produces far too many lines to fit into the display screen all at once, and thus only the final messages are visible.
However, the output can be redirected to the less command through the use of a pipe (designated by the vertical bar character),
thereby allowing the startup messages to be viewed one screenful at a time:
dmesg | less
|dmesg | less|
less allows the output to be moved forward one screenful at a time by pressing the SPACE bar, backward by pressing the b key and removed by pressing the q key.
(The more command could have been used here instead of the less command; however,
less is newer than more and has additional functions, including the ability to return to previous pages of the output.)
dmesg > boot_messages
dmesg > boot_messages
When a user encounters a problem with the system, it can be convenient to write the output of dmesg to a file
and then send that file by e-mail to a system administrator or other knowledgeable person for assistance.
For example, the output could be redirected to a file named boot_messages using the output redirection operator
(designated by a rightward facing angle bracket). Note when you give in this command in your Terminal and press Enter, you found the text file in your Home Folder.
dmesg | grep -i usb
|dmesg | grep -i usb|
Because of the length of the output of dmesg, it can be convenient to pipe its output to grep,
a filter which searches for any lines that contain the string (i.e., sequence of characters) following it.
The -i option can be used to tell grep to ignore the case (i.e., lower case or upper case) of the letters in the string.
For example, the following command lists all references to USB (universal serial bus) devices in the kernel messages.
dmesg | grep -i tty
|dmesg | grep -i tty|
And this command tells dmesg to show all serial ports (which are represented by the string tty).
dmesg | grep -i memory
|dmesg | grep -i memory|
The dmesg and grep combination can also be used to show how much physical memory (i.e., RAM) is available on the system:
dmesg | grep -i dma
This command checks to confirm that the HDD(s) is running in DMA (direct memory access) mode.