1, introduction to
The dmesg command is used to display the kernel information, use the dmesg can be effective in the diagnosis of machine hardware failures or add hardware problems, in addition, using the dmesg can decide what your server installed hardware, each system restart, the system will check all the hardware to record information, execute the/bin/dmesg can view the record, boot information is stored in the/var/log directory, and file name for the dmesg,
2, the dmesg command format commonly used
[root @ RedHat_test ~] # dmesg [-] [-s & lt; buffer size & gt;]
- c: when type displays the contents of a ring buffer after remove,
-s: buffer size, define a buffer size for "buffer size" is used to query the kernel ring buffer, the default size of 8196 (the default size and 2.0.33 and 2.1.103 kernel syslog buffer size), if you set up a ring buffer is greater than the default value, then you can use this option to define a considerable buffer to see the full ring buffer content,
- n: level, set the level to record the console to start the level of information, for example, n - 1 refers to the level set to the lowest level, in addition to the kernel panic message does not display information to the console, all levels of the startup information will also be recorded/proc/KMSG, file, therefore, syslogd (8) can also be used to control the output of the information, when using the -n option, the contents of the dmesg will not remove the kernel ring buffer, when using the above two options at the same time, only a final option that will work,
3, will be saved to a file system startup information
/root @ RedHat_test ~ # dmesg & gt; Messages. TXT
4, single page output
/root @ RedHat_test ~ # dmesg | more
/root @ RedHat_test ~ # dmesg | less
5, in the form of readability good output information
/root @ RedHat_test ~ # dmesg -h
The hierarchy of 6, set the record information
/root @ RedHat_test ~ # dmesg - n 3
7, print memory
/root @ RedHat_test ~ # dmesg | tail -f # print latest information
/root @ RedHat_test ~ # dmesg | head - 20 # print before 20 lines of information
/root @ RedHat_test ~ # dmesg | tail - # 20 printing last 20 rows log
8, real-time monitoring of the output of dmesg log information
[root @ RedHat_test ~] # watch "dmesg | tail - 20"
9, the search is detected hardware containing the specified string
/root @ RedHat_test ~ # dmesg | grep operation mode of the DMA # to check the hard drive
/root @ RedHat_test ~ # dmesg | grep eth # check the Ethernet connection information
/root @ RedHat_test ~ # dmesg | grep sda # to check the hard disk device
/root @ RedHat_test ~ # dmesg | grep ttyS * # to check the related information of the serial port
/root @ RedHat_test ~ # dmesg | grep -i memory # for memory status
/root @ RedHat_test ~ # dmesg | grep -i usb # to check the usb interface
/root @ RedHat_test ~ # dmesg | egrep -i "(apm | acpi)" # detection system kernel module, detecting acpi loading condition
10, email will boot information
/root @ RedHat_test ~ # dmesg & gt; The boot. Messages
/root @ RedHat_test ~ # mail -s "Boot Log of Linux Server"
[email protected] 11, print and eliminate the kernel ring buffer
/root @ RedHat_test ~ # dmesg -c