In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use the dmesg command in linux to handle failures and view system information. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The dmesg' command displays the ring buffer information of the linux kernel, from which we can get a lot of system information about multiple runtime levels, such as system architecture, cpu, mounted hardware, RAM, and so on. When the computer starts, the system kernel (the core part of the operating system) will be loaded into memory. A lot of information is displayed during the loading process, in which we can see that the kernel detects hardware devices.
An example of using the dmesg command
Dmesg' commands the diagnosis of equipment faults is very important. When we connect or disconnect the hardware with the help of the 'dmesg' command, we can see the detection or disconnection information of the hardware.' The dmesg' command can be used in most Linux and Unix-based operating systems.
Below we show some of the most famous' dmesg' command tools and examples of their practical use.' The syntax for using the dmesg' command is as follows.
# dmesg [options...]
1. List all drivers loaded into the kernel
We can use things such as' more'. The 'tail',' less'or 'grep' word processing tool' handles the output of the 'dmesg' command. Since the output of the dmesg log is not suitable for full display on one page, we use the pipe pipe) to send its output to the more or less command for single-page display.
[root@tecmint.com ~] # dmesg | more
[root@tecmint.com ~] # dmesg | less
.
two。 List all detected hardware
To display all hard disk devices detected by the kernel, you can search for the sda' keyword using the 'grep' command' as follows:
[root@tecmint.com ~] # dmesg | grep sda
[1.280971] sd 2 GB/232 GiB 0: [sda] 488281250 GB/232 GiB
[1.281014] sd 2:0:0:0: [sda] Write Protect is off
[1.281016] sd 2:0:0:0: [sda] Mode Sense: 00 3a 00 00
[1.281039] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[1.359585] sda: sda1 sda2
< sda5 sda6 sda7 sda8 >[1.360052] sd 2:0:0:0: [sda] Attached SCSI disk
[2.347887] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
[22.928440] Adding 3905532k swap on / dev/sda6. Priority:-1 extents:1 across:3905532k FS
[23.950543] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro
[24.134016] EXT4-fs (sda5): mounted filesystem with ordered data mode. Opts: (null)
[24.330762] EXT4-fs (sda7): mounted filesystem with ordered data mode. Opts: (null)
[24.561015] EXT4-fs (sda8): mounted filesystem with ordered data mode. Opts: (null)
Note 'sda'' for the first SATA hard drive and 'sdb' for the second SATA hard drive. If you want to view the IDE hard drive search for 'hda'' or 'hdb'' keywords.
3. Output only the first 20 lines of the dmesg command log
Follow the 'dmesg' command' head' command to display the first few lines, and the 'dmesg | head-20' command will display the first 20 lines.
[root@tecmint.com ~] # dmesg | head-20
4. Output only the last 20 lines of log of dmesg command
After the 'dmesg' command, follow the' tail' command 'dmesg | tail-20') to output the last 20 lines of the dmesg' command, which is useful when you plug in a removable device.
[root@tecmint.com ~] # dmesg | tail-20
5. Search for detected hardware that contains a specific string
Because the output of the 'dmesg' command is simply too long, it is very difficult to search for a particular string in it. 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 case is ignored.
[root@tecmint.com log] # dmesg | grep-I usb
[root@tecmint.com log] # dmesg | grep-I dma
[root@tecmint.com log] # dmesg | grep-I tty
[root@tecmint.com log] # dmesg | grep-I memory
6. Clear the dmesg buffer log
We can use the following command to empty the dmesg log. This command clears the logs in the dmesg ring buffer. But you can still view the logs stored in the'/ var/log/dmesg' file. Any device you connect will generate dmesg log output.
[root@tecmint.com log] # dmesg-c
7. Real-time monitoring dmesg log output
In some distributions, you can use the command 'tail-f / var/log/dmesg' to monitor the log output of dmesg in real time.
[root@tecmint.com log] # watch "dmesg | tail-20"
Thank you for reading! On "how to use dmesg commands in linux to deal with failures and view system information" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 249
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.