Linux command------DMESG

Source: Internet
Author: User
Tags dmesg

The information printed in the driver development using the function PRINTK () can be viewed through DMESG

Brief introduction

The ' DMESG ' command displays the ring buffer information for the Linux kernel, where we can obtain a large amount of system information, such as system architecture, CPU, mounted hardware, RAM, and many other operational levels. When the computer starts, the system kernel (the core part of the operating system) is loaded into memory. A lot of information is displayed during the loading process, in which we can see the hardware devices detected by the kernel.

Example of using the DMESG command

The ' DMESG ' command to diagnose a device failure is very important. When hardware is connected or disconnected with the help of the ' dmesg ' command, we can see the hardware detection or disconnection information. The ' DMESG ' command is available in most Linux and UNIX-based operating systems.

We can use such as ' more '. ' Tail ', ' less ' or ' grep ' word processing tool to handle the output of the ' DMESG ' command. Because the output of the DMESG log is not intended to be fully displayed on a single page, we use a pipe to send its output to the more or less command-page display.

 more Less

Follow the ' head ' command after the ' DMESG ' command to display the starting lines, ' DMESG | The head-20′ command displays the first 20 lines that begin.

Head  -

Follow the ' tail ' command after the ' DMESG ' command (' DMESG | Tail-20 ') to output the last 20 lines of the ' DMESG ' command, which is useful when you plug in a removable device.

Tail -

Because the output of the ' DMESG ' command is too long, it is very difficult to search for a particular string. Therefore, it is necessary to filter out some log lines that contain strings such as ' USB ' DMA ' TTY ' memory '. The '-i ' option of the grep command indicates that the case is ignored.

 grep -grep -grep -grep -I memory

We can use the following command to empty the DMESG log. This command empties the log in the DMESG ring buffer. However, you can still view the logs stored in the '/VAR/LOG/DMESG ' file. Any device you connect to will generate DMESG log output.

[Email protected] log]# dmesg-c

In some distributions, the command ' tail-f/VAR/LOG/DMESG ' can be used to monitor DMESG log output in real time. Watch-n 2 "DMESG | Tail-20 "represents the contents of a 2s periodic execution of quotes

" DMESG | tail-20 "

Linux command------DMESG

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.