Linux command
lshw 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
List all hardware in compact table
sudo lshw -short
Show CPU information
sudo lshw -class processor
Show disk and storage devices
sudo lshw -class disk -class storage -short
Show network hardware
sudo lshw -class network
Output as JSON
sudo lshw -json
Save network info as HTML
sudo lshw -class network -html > network.html
Strip sensitive information
sudo lshw -sanitize
说明
lshw (Hardware Lister) extracts detailed information about the hardware configuration of the machine. It can report on memory, firmware, CPU, bus, disk, network, and other hardware configurations.
参数
- -class CLASS
- Show only specified hardware class (can repeat)
- -short
- Output hardware paths in compact tabular format
- -businfo
- Output bus information
- -X
- Launch graphical interface (if available)
- -html
- Output as HTML
- -xml
- Output as XML
- -json
- Output as JSON
- -sanitize
- Remove sensitive information (IPs, serials)
- -numeric
- Output numeric IDs
- -quiet
- Suppress status messages
- -notime
- Exclude timing information from output
- -enable TEST
- Enable specific test
- -disable TEST
- Disable specific test
FAQ
What is the lshw command used for?
lshw (Hardware Lister) extracts detailed information about the hardware configuration of the machine. It can report on memory, firmware, CPU, bus, disk, network, and other hardware configurations.
How do I run a basic lshw example?
Run `sudo lshw -short` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -class CLASS do in lshw?
Show only specified hardware class (can repeat)