lshw 是一个读取硬件信息的命令行工具。
archlinux 默认并没有安装 lshw,你需要手工安装
sudo pacman -S lshw
注意: 由于 lshw 需要读取硬件信息,因此需要使用 root 权限
直接运行 lshw 就能列出本机上的硬件信息了:
sudo lshw
结果为:
若你觉得输出很乱,其实 lshw 也提供了一个 GUI 界面给你使用。
lshw -X

通过 -businfo 可以获取主线信息
sudo lshw -businfo
结果为:
Bus info Device Class Description
======================================================
system F31
bus F31
memory 102KiB BIOS
cpu@0 processor Intel(R) Pentium(R) Dual CPU T2330
memory 64KiB L1 cache
memory 1MiB L2 cache
memory 4GiB System Memory
memory 2GiB DIMM DDR2 Synchronous 533 MHz (1
memory 2GiB DIMM DDR2 Synchronous 533 MHz (1
pci@0000:00:00.0 bridge Mobile PM965/GM965/GL960 Memory Contr
pci@0000:00:02.0 display Mobile GM965/GL960 Integrated Graphic
pci@0000:00:02.1 display Mobile GM965/GL960 Integrated Graphic
pci@0000:00:1a.0 bus 82801H (ICH8 Family) USB UHCI Control
usb@3 usb3 bus UHCI Host Controller
pci@0000:00:1a.1 bus 82801H (ICH8 Family) USB UHCI Control
usb@4 usb4 bus UHCI Host Controller
pci@0000:00:1a.7 bus 82801H (ICH8 Family) USB2 EHCI Contro
usb@1 usb1 bus EHCI Host Controller
pci@0000:00:1b.0 multimedia 82801H (ICH8 Family) HD Audio Control
pci@0000:00:1c.0 bridge 82801H (ICH8 Family) PCI Express Port
pci@0000:02:00.0 network BCM4311 802.11b/g WLAN
pci@0000:00:1c.1 bridge 82801H (ICH8 Family) PCI Express Port
pci@0000:00:1c.5 bridge 82801H (ICH8 Family) PCI Express Port
pci@0000:06:00.0 enp6s0 network NetLink BCM5906M Fast Ethernet PCI Ex
pci@0000:00:1d.0 bus 82801H (ICH8 Family) USB UHCI Control
usb@5 usb5 bus UHCI Host Controller
pci@0000:00:1d.1 bus 82801H (ICH8 Family) USB UHCI Control
usb@6 usb6 bus UHCI Host Controller
usb@6:1 input USB Optical Mouse
pci@0000:00:1d.2 bus 82801H (ICH8 Family) USB UHCI Control
usb@7 usb7 bus UHCI Host Controller
pci@0000:00:1d.7 bus 82801H (ICH8 Family) USB2 EHCI Contro
usb@2 usb2 bus EHCI Host Controller
usb@2:1 generic 802.11n NIC
usb@2:2 storage OnlyDisk
usb@2:4 multimedia Lenovo EasyCamera
pci@0000:00:1e.0 bridge 82801 Mobile PCI Bridge
pci@0000:07:09.0 bus R5C832 IEEE 1394 Controller
pci@0000:07:09.1 generic R5C822 SD/SDIO/MMC/MS/MSPro Host Adap
pci@0000:07:09.2 generic R5C592 Memory Stick Bus Host Adapter
pci@0000:07:09.3 generic xD-Picture Card Controller
pci@0000:00:1f.0 bridge 82801HM (ICH8M) LPC Interface Control
pci@0000:00:1f.1 storage 82801HM/HEM (ICH8M/ICH8M-E) IDE Contr
pci@0000:00:1f.2 storage 82801HM/HEM (ICH8M/ICH8M-E) SATA Cont
pci@0000:00:1f.3 bus 82801H (ICH8 Family) SMBus Controller
power 35329
scsi@5 scsi5 storage
lxdbr0 network Ethernet interface
usb@2:1 wlp0s29f7u1 network Wireless interface
docker0 network Ethernet interface
lshw 可以将信息以 html,xml 或 json 的格式进行输出:
# lshw -html
# lshw -xml
lshw -json
结果为:
这样就很容易用 jq 之类的信息从中抽取信息了。
默认情况下,lshw 会隐藏IP地址、serial number 之类的敏感信息,若你希望把这类信息也显示出来,则可以执行
sudo lshw -sanitize
lshw -help
会在 stderr 中显示简单的参数说明:
Hardware Lister (lshw) - unknown
usage: lshw [-format] [-options ...]
lshw -version
-version print program version (unknown)
format can be
-html output hardware tree as HTML
-xml output hardware tree as XML
-short output hardware paths
-businfo output bus information
-X use graphical interface
options can be
-class CLASS only show a certain class of hardware
-C CLASS same as '-class CLASS'
-c CLASS same as '-class CLASS'
-disable TEST disable a test (like pci, isapnp, cpuid, etc. )
-enable TEST enable a test (like pci, isapnp, cpuid, etc. )
-quiet don't display status
-sanitize sanitize output (remove sensitive information like serial numbers, etc.)
-numeric output numeric IDs (for PCI, USB, etc.)
-notime exclude volatile attributes (timestamps) from output
