lshw命令来自英文词组“list hardware”的缩写,其功能是用于查看硬件设备信息。lshw命令能够显示Linux系统中的内存配置、固件版本、主板配置、CPU版本和速度、总线速度等丰富的硬件设备信息。

语法格式:lshw [参数]

常用参数:

-C设置设备类型
-X启动图形界面
-businfo显示总线相关信息
-enable test启动测试模式
-html使用html格式输出结果
-help显示帮助信息
-json使用json格式输出结果
-numeric显示设备的数字ID
-quiet静默执行模式
-short使用简要信息模式
-sanitize移除敏感信息
-version显示版本信息
-xml使用xml格式输出结果

参考示例

使用简要信息模式,显示当前系统的全部硬件设备信息:

[root@linuxcool ~]# lshw -short
H/W path           Device      Class      Description
=====================================================
                               system     VMware Virtual Platform
/0                             bus        440BX Desktop Reference Platform
/0/0                           memory     86KiB BIOS
/0/1                           processor  Intel(R) Core(TM) i5-9300H CPU @ 2.40G
/0/1/0                         memory     16KiB L1 cache
/0/1/1                         memory     16KiB L1 cache
/0/2                           processor  CPU
/0/5                           processor  CPU
………………省略部分输出信息………………

显示当前系统的总线设备相关信息:

[root@linuxcool ~]# lshw -businfo
Bus info          Device      Class      Description
====================================================
                              system     VMware Virtual Platform
                              bus        440BX Desktop Reference Platform
                              memory     86KiB BIOS
cpu@0                         processor  Intel(R) Core(TM) i5-9300H CPU @ 2.40GH
                              memory     16KiB L1 cache
                              memory     16KiB L1 cache
cpu@1                         processor  CPU
cpu@2                         processor  CPU
………………省略部分输出信息………………

显示当前系统的内存设备相关信息:

[root@linuxcool ~]# lshw -C memory
  *-firmware                
       description: BIOS
       vendor: Phoenix Technologies LTD
       physical id: 0
       version: 6.00
       date: 11/12/2020
       size: 86KiB
       capabilities: isa pci pcmcia pnp apm upgrade shadowing escd cdboot bootselect edd int5printscreen int9keyboard int14serial int17printer int10video acpi smartbattery biosbootspecification netboot
  *-cache:0
       description: L1 cache
       physical id: 0
       slot: L1
       size: 16KiB
       capacity: 16KiB
       capabilities: asynchronous internal write-back
       configuration: level=1
………………省略部分输出信息………………
Author

这篇优质的内容由TA贡献而来

刘遄

《Linux就该这么学》书籍作者,RHCA认证架构师,教育学(计算机专业硕士)。