lshw linux

Linux lshw command lists all the hardware configuration of the system.

Linux lshw命令列出了系统的所有硬件配置。

Some of the common information we can extract from the lshw command are:

我们可以从lshw命令提取的一些常见信息是:

  • RAM Memory informationRAM内存信息
  • CPU configurationsCPU配置
  • Motherboard information主板信息
  • Harddisk information硬盘信息
  • Network devices information网络设备信息

Linux lshw命令功能 (Linux lshw Command Features)

  • Ability to produce the output in various formats such as XML, JSON, and HTML.能够产生各种格式的输出,例如XML,JSON和HTML。
  • We can dump the output to a file easily using the redirection operator.我们可以使用重定向运算符轻松地将输出转储到文件中。
  • The default output contains a lot of information, we can get specific hardware information using various options.默认输出包含很多信息,我们可以使用各种选项来获取特定的硬件信息。
  • Supports GUI too, useful for Desktop environments only. Most of the time, we run these commands on a Linux server where we don’t have GUI software.也支持GUI,仅对桌面环境有用。 大多数时候,我们在没有GUI软件的Linux服务器上运行这些命令。

lshw命令限制 (lshw command limitations)

  • It doesn’t detect Firewire devices as of now.到目前为止,它还没有检测到Firewire设备。
  • It must be run as a superuser, either root or with sudo, to get the correct hardware details.它必须以超级用户身份(以root或sudo身份)运行,以获取正确的硬件详细信息。
  • I found that -dump option to save the output in a file is not working.我发现-dump选项无法将输出保存到文件中。

Linux硬件信息示例 (Linux Hardware Information Examples)

Let’s look at some examples to get the linux hardware information using the lshw command.

让我们看一些使用lshw命令获取linux硬件信息的示例。

1.获取完整的Linux硬件信息 (1. Getting Complete Linux Hardware Information)


root@localhost:~# sudo lshw
localhost                   description: Computerproduct: Standard PC (Q35 + ICH9, 2009)vendor: QEMUversion: pc-q35-3.1width: 64 bitscapabilities: smbios-2.8 dmi-2.8 vsyscall32configuration: boot=normal*-coredescription: Motherboardphysical id: 0*-firmwaredescription: BIOSvendor: SeaBIOSphysical id: 0version: rel-1.12.0-0-ga698c8995f-prebuilt.qemu.orgdate: 04/01/2014size: 96KiB*-cpudescription: CPUproduct: AMD EPYC 7501 32-Core Processorvendor: Advanced Micro Devices [AMD]physical id: 400bus info: cpu@0version: pc-q35-3.1slot: CPU 0size: 2GHzcapacity: 2GHzwidth: 64 bitscapabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt pdpe1gb rdtscp x86-64 rep_good nopl cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw perfctr_core ssbd ibpb vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 virt_ssbd aratconfiguration: cores=1 enabledcores=1 threads=1*-memorydescription: System Memoryphysical id: 1000size: 2GiBcapacity: 2GiBcapabilities: eccconfiguration: errordetection=multi-bit-ecc*-bankdescription: DIMM RAMvendor: QEMUphysical id: 0slot: DIMM 0size: 2GiB*-pcidescription: Host bridgeproduct: 82G33/G31/P35/P31 Express DRAM Controllervendor: Intel Corporationphysical id: 100bus info: pci@0000:00:00.0version: 00width: 32 bitsclock: 33MHz*-display UNCLAIMEDdescription: VGA compatible controllerphysical id: 1bus info: pci@0000:00:01.0version: 02width: 32 bitsclock: 33MHzcapabilities: vga_controllerconfiguration: latency=0resources: memory:fd000000-fdffffff memory:febd0000-febd0fff memory:c0000-dffff*-scsi:0description: SCSI storage controllerproduct: Virtio SCSIvendor: Red Hat, Inc.physical id: 2bus info: pci@0000:00:02.0version: 00width: 64 bitsclock: 33MHzcapabilities: scsi msix bus_master cap_listconfiguration: driver=virtio-pci latency=0resources: irq:22 ioport:c000(size=64) memory:febd1000-febd1fff memory:fe000000-fe003fff*-virtio0 UNCLAIMEDdescription: Virtual I/O devicephysical id: 0bus info: virtio@0configuration: driver=virtio_scsi*-scsi:1description: SCSI storage controllerproduct: Virtio SCSIvendor: Red Hat, Inc.physical id: 3bus info: pci@0000:00:03.0version: 00width: 64 bitsclock: 33MHzcapabilities: scsi msix bus_master cap_listconfiguration: driver=virtio-pci latency=0resources: irq:23 ioport:c040(size=64) memory:febd2000-febd2fff memory:fe004000-fe007fff*-virtio1 UNCLAIMEDdescription: Virtual I/O devicephysical id: 0bus info: virtio@1configuration: driver=virtio_scsi*-networkdescription: Ethernet controllerproduct: Virtio network devicevendor: Red Hat, Inc.physical id: 4bus info: pci@0000:00:04.0version: 00width: 64 bitsclock: 33MHzcapabilities: msix bus_master cap_list romconfiguration: driver=virtio-pci latency=0resources: irq:20 ioport:c0c0(size=32) memory:febd3000-febd3fff memory:fe008000-fe00bfff memory:feb80000-febbffff*-virtio2description: Ethernet interfacephysical id: 0bus info: virtio@2logical name: eth0serial: f2:3c:92:d4:76:9ecapabilities: ethernet physicalconfiguration: autonegotiation=off broadcast=yes driver=virtio_net driverversion=1.0.0 ip=45.79.122.188 link=yes multicast=yes*-isadescription: ISA bridgeproduct: 82801IB (ICH9) LPC Interface Controllervendor: Intel Corporationphysical id: 1fbus info: pci@0000:00:1f.0version: 02width: 32 bitsclock: 33MHzcapabilities: isaconfiguration: driver=lpc_ich latency=0resources: irq:0*-storagedescription: SATA controllerproduct: 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode]vendor: Intel Corporationphysical id: 1f.2bus info: pci@0000:00:1f.2version: 02width: 32 bitsclock: 33MHzcapabilities: storage msi ahci_1.0 bus_master cap_listconfiguration: driver=ahci latency=0resources: irq:31 ioport:c0e0(size=32) memory:febd4000-febd4fff*-serial UNCLAIMEDdescription: SMBusproduct: 82801I (ICH9 Family) SMBus Controllervendor: Intel Corporationphysical id: 1f.3bus info: pci@0000:00:1f.3version: 02width: 32 bitsclock: 33MHzconfiguration: latency=0resources: ioport:700(size=64)*-scsi:0physical id: 1logical name: scsi0*-diskdescription: EXT4 volumeproduct: QEMU HARDDISKvendor: Linuxphysical id: 0.0.0bus info: scsi@0:0.0.0logical name: /dev/sdalogical name: /version: 1.0serial: ccf427b1-b94a-4237-b067-d9e9fc34756fsize: 49GiBcapabilities: 5400rpm journaled extended_attributes large_files huge_files dir_nlink recover extents ext4 ext2 initializedconfiguration: ansiversion=5 created=2020-02-19 14:27:58 filesystem=ext4 lastmountpoint=/ logicalsectorsize=512 modified=2020-04-28 08:10:42 mount.fstype=ext4 mount.options=rw,relatime,errors=remount-ro,data=ordered mounted=2020-04-28 08:10:43 sectorsize=512 state=mounted*-scsi:1physical id: 2logical name: scsi1*-diskdescription: Linux swap volumeproduct: QEMU HARDDISKvendor: QEMUphysical id: 0.1.2bus info: scsi@1:0.1.2logical name: /dev/sdbversion: 1serial: 179fdb40-6f5a-4973-99fd-2c0dfee57907size: 512MiBcapacity: 512MiBcapabilities: 5400rpm swap initializedconfiguration: ansiversion=5 filesystem=swap logicalsectorsize=512 pagesize=4096 sectorsize=512
root@localhost:~# 

As you can see that it’s a lot of information, if you want quick hardware information, then run it with -short option.

如您所见,其中包含很多信息,如果您需要快速的硬件信息,请使用-short选项运行它。


root@localhost:~# sudo lshw -short
H/W path     Device    Class      Description
=============================================system     Standard PC (Q35 + ICH9, 2009)
/0                     bus        Motherboard
/0/0                   memory     96KiB BIOS
/0/400                 processor  AMD EPYC 7501 32-Core Processor
/0/1000                memory     2GiB System Memory
/0/1000/0              memory     2GiB DIMM RAM
/0/100                 bridge     82G33/G31/P35/P31 Express DRAM Controller
/0/100/1               display    VGA compatible controller
/0/100/2               storage    Virtio SCSI
/0/100/2/0             generic    Virtual I/O device
/0/100/3               storage    Virtio SCSI
/0/100/3/0             generic    Virtual I/O device
/0/100/4               network    Virtio network device
/0/100/4/0   eth0      network    Ethernet interface
/0/100/1f              bridge     82801IB (ICH9) LPC Interface Controller
/0/100/1f.2            storage    82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode]
/0/100/1f.3            bus        82801I (ICH9 Family) SMBus Controller
/0/1         scsi0     storage
/0/1/0.0.0   /dev/sda  volume     49GiB QEMU HARDDISK
/0/2         scsi1     storage
/0/2/0.1.2   /dev/sdb  volume     512MiB QEMU HARDDISK
root@localhost:~#

2.获取Linux CPU信息 (2. Getting Linux CPU Information)

We can run lshw -C class_name to get the specific hardware class information. Let’s see how to get the CPU information.

我们可以运行lshw -C class_name来获取特定的硬件类信息。 让我们看看如何获​​取CPU信息。


root@localhost:~# sudo lshw -C cpu*-cpu                     description: CPUproduct: AMD EPYC 7501 32-Core Processorvendor: Advanced Micro Devices [AMD]physical id: 400bus info: cpu@0version: pc-q35-3.1slot: CPU 0size: 2GHzcapacity: 2GHzwidth: 64 bitscapabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt pdpe1gb rdtscp x86-64 rep_good nopl cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw perfctr_core ssbd ibpb vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 virt_ssbd aratconfiguration: cores=1 enabledcores=1 threads=1
root@localhost:~#

If you have multiple CPUs, then the command will provide information of all the CPUs.

如果您有多个CPU,则该命令将提供所有CPU的信息。

The lshw -C processor command will also print the CPU information.

lshw -C processor命令还将打印CPU信息。

If you are not sure of the Class name, then look at it in the lshw short output.

如果不确定类名,请在lshw short输出中查看它。

3.获取Linux内存信息 (3. Getting Linux Memory Information)


root@localhost:~# sudo lshw -C memory*-firmware                description: BIOSvendor: SeaBIOSphysical id: 0version: rel-1.12.0-0-ga698c8995f-prebuilt.qemu.orgdate: 04/01/2014size: 96KiB*-memorydescription: System Memoryphysical id: 1000size: 2GiBcapacity: 2GiBcapabilities: eccconfiguration: errordetection=multi-bit-ecc*-bankdescription: DIMM RAMvendor: QEMUphysical id: 0slot: DIMM 0size: 2GiB
root@localhost:~#

4.获取Linux硬盘信息 (4. Getting Linux Harddisk Information)


root@localhost:~# sudo lshw -C storage

5.获取Linux主板信息 (5. Getting Linux Motherboard Information)


root@localhost:~# sudo lshw -C bus*-core                    description: Motherboardphysical id: 0*-serial UNCLAIMEDdescription: SMBusproduct: 82801I (ICH9 Family) SMBus Controllervendor: Intel Corporationphysical id: 1f.3bus info: pci@0000:00:1f.3version: 02width: 32 bitsclock: 33MHzconfiguration: latency=0resources: ioport:700(size=64)
root@localhost:~#

6.获取Linux网络接口信息 (6. Getting Linux Network Interfaces Information)


root@localhost:~# sudo lshw -C network*-network                 description: Ethernet controllerproduct: Virtio network devicevendor: Red Hat, Inc.physical id: 4bus info: pci@0000:00:04.0version: 00width: 64 bitsclock: 33MHzcapabilities: msix bus_master cap_list romconfiguration: driver=virtio-pci latency=0resources: irq:20 ioport:c0c0(size=32) memory:febd3000-febd3fff memory:fe008000-fe00bfff memory:feb80000-febbffff*-virtio2description: Ethernet interfacephysical id: 0bus info: virtio@2logical name: eth0serial: f2:3c:92:d4:76:9ecapabilities: ethernet physicalconfiguration: autonegotiation=off broadcast=yes driver=virtio_net driverversion=1.0.0 ip=45.79.122.188 link=yes multicast=yes
root@localhost:~#

7. HTML,XML和JSON格式的Linux硬件信息 (7. Linux Hardware Information in HTML, XML, and JSON Formats )

The default output of lshw command is in plain text. We can get the output in HTML, XML, and JSON formats by specifying corresponding options.

lshw命令的默认输出为纯文本。 通过指定相应的选项,我们可以获得HTML,XML和JSON格式的输出。

XML:

XML:


root@localhost:~# sudo lshw -C bus -xml
<?xml version="1.0" standalone="yes" ?>
<!-- generated by lshw-B.02.18 -->
<!-- GCC 7.3.0 -->
<!-- Linux 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 x86_64 -->
<!-- GNU libc 2 (glibc 2.27) -->
<list><node id="core" claimed="true" class="bus" handle=""><description>Motherboard</description><physid>0</physid><node id="serial" class="bus" handle="PCI:0000:00:1f.3"><description>SMBus</description><product>82801I (ICH9 Family) SMBus Controller</product><vendor>Intel Corporation</vendor><physid>1f.3</physid><businfo>pci@0000:00:1f.3</businfo><version>02</version><width units="bits">32</width><clock units="Hz">33000000</clock><configuration><setting id="latency" value="0" /></configuration><resources><resource type="ioport" value="700(size=64)" /></resources></node></node>
</list>
root@localhost:~#

JSON:

JSON:


root@localhost:~# sudo lshw -C memory -json{                 "id" : "firmware","class" : "memory","claimed" : true,"description" : "BIOS","vendor" : "SeaBIOS","physid" : "0","version" : "rel-1.12.0-0-ga698c8995f-prebuilt.qemu.org","date" : "04/01/2014","units" : "bytes","size" : 98304},{"id" : "memory","class" : "memory","claimed" : true,"handle" : "DMI:1000","description" : "System Memory","physid" : "1000","units" : "bytes","size" : 2147483648,"capacity" : 2147483648,"configuration" : {"errordetection" : "multi-bit-ecc"},"capabilities" : {"ecc" : "Multi-bit error-correcting code (ECC)"},"children" : [{"id" : "bank","class" : "memory","claimed" : true,"handle" : "DMI:1100","description" : "DIMM RAM","vendor" : "QEMU","physid" : "0","slot" : "DIMM 0","units" : "bytes","size" : 2147483648}]},root@localhost:~#

HTML:

HTML:


root@localhost:~# sudo lshw -C memory -html

8.将Linux硬件信息保存到文件中 (8. Saving Linux Hardware Information to a File)

I tried to use the -dump option with the lshw command but it didn’t worked for me. But, we can always use the redirection operator (>) to save it into a new file.

我尝试将-dump选项与lshw命令一起使用,但对我而言不起作用。 但是,我们始终可以使用重定向运算符(>)将其保存到新文件中。


# sudo lshw -html > hardware_info.html
Linux Hardware Information – lshw Html File
Linux硬件信息– lshw HTML文件

结论 (Conclusion)

Linux lshw command is a simple tool to get the complete hardware information. The various options to get the specific hardware information and in multiple formats such as HTML and JSON is very useful in sharing the details with others also.

Linux lshw命令是获取完整硬件信息的简单工具。 获取特定硬件信息以及多种格式(例如HTML和JSON)的各种选项对于与其他人共享详细信息也非常有用。

Reference: HardwareLiSter

参考 : HardwareLiSter

翻译自: https://www.journaldev.com/39487/linux-lshw-command-linux-hardware-info

lshw linux

lshw linux_Linux lshw命令–获取Linux硬件信息相关推荐

  1. linux硬件命令大全,Linux硬件信息命令大全

    硬件信息 在linux系统中,有很多命令可以用于查询主机的硬件信息,有些命令仅仅针对于特定的硬件部件,比如cpu,内存等,而有些命令可以查询很多的硬件信息. 这篇帖子简单地带大家了解一下最常用的查询各 ...

  2. 如何使用python-hwinfo获取Linux硬件信息?

    2019独角兽企业重金招聘Python工程师标准>>> 导读 到目前为止,我们已经介绍了大部分获取 Linux 系统硬件信息和配置的工具,不过也有许多命令可用于相同目的.而且,一些工 ...

  3. python 怎样调用硬件_如何使用python-hwinfo获取Linux硬件信息?

    导读 到目前为止,我们已经介绍了大部分获取 Linux 系统硬件信息和配置的工具,不过也有许多命令可用于相同目的.而且,一些工具会显示所有硬件组件的详细信息,或只显示特定设备的信息.在这个系列中, 今 ...

  4. 查看Linux硬件信息命令的使用

    为什么80%的码农都做不了架构师?>>>    查看Linux硬件信息命令的使用 http://www.xxlinux.com/newxxlinux/syste ... 5/315. ...

  5. 抓取一台电脑linux,教程方法;用来获取Linux主机信息的5个常用命令电脑技巧-琪琪词资源网...

    琪琪词资源网-教程方法;用来获取Linux主机信息的5个常用命令电脑技巧,以下是给大家带来的教程方法;用来获取Linux主机信息的5个常用命令,大家可以了解一下哦! 有些时候Linux 系统管理员在接 ...

  6. linux查询主机信息命令,用来获取Linux主机信息的5个常用命令

    有些时候Linux 系统管理员在接手一台新的服务器时,如果没有好的交接文档,我们想要得到的主机信息就只能靠自己了.很多主机信息是可以直接通过命令从主机上获得的,本文就与大家分享 5 个获取 Linux ...

  7. python将Linux下使用top命令获取的进程信息进行分析做可视化展示

    python将Linux下使用top命令获取的进程信息进行分析做可视化展示 版本 版本 作者 日期 备注 v1.0 ZY 2020.11.10 初版完成 文章目录 python将Linux下使用top ...

  8. python获取电脑硬件信息_Python实现的读取电脑硬件信息功能示例

    本文实例讲述了Python实现的读取电脑硬件信息功能.分享给大家供大家参考,具体如下: 上学那会,老师让我用java获取电脑硬件信息,CPU, 硬盘,MAC等,那个时候感觉搞了好久...... 今天, ...

  9. Python获取电脑硬件信息及状态的实现方法

    From: http://www.jb51.net/article/54470.htm 这篇文章主要介绍了Python获取电脑硬件信息及状态的实现方法,是一个很实用的技巧,需要的朋友可以参考下 本文以 ...

最新文章

  1. CCNA的一个综合实验(经典)
  2. ad 原理图差分线_usb hub原理图及pcb设计
  3. 10x系列之Clay.io的服务发现
  4. 【NLP】相当全面:各种深度学习模型在文本分类任务上的应用
  5. SpringBoot2.0 以上 WebMvcConfigurerAdapter 方法过时 解决办法
  6. GMQ稳定币为区块链资产在金融市场的进一步应用打开了一扇大门
  7. eclipse-连接TFS错误 the server to respond with a valid http response解决方法
  8. 基于GDAL库,读取海洋风场数据(.nc格式)c++版
  9. 六种常用的物联网通信协议
  10. git常用操作命令大全
  11. html动态图标代码,SVG动态图标是如何实现的
  12. 什么是ie浏览器_关于几款电脑浏览器的使用感受,你用过吗?
  13. Upload LABS Pass-5
  14. 帝国cms后台不停的登录成功
  15. vcard文件怎么导入手机_如何在Outlook 2013中将联系人导出到vCard(.vcf)文件或从vCard文件导入联系人...
  16. 如何利用巨象指纹浏览器在twitter上找到精准客户
  17. Excel 2010 SQL应用117 分组统计之GROUP BY 与First
  18. YGG 在 Branch.gg 的免费游戏 Castaways 中购买了 Genesis NFT
  19. 支付宝手机网站支付补全信息提示 系统综合评估签约条件不满足解决
  20. JavaScript经典pdf书籍推荐

热门文章

  1. uml定义的使用的关系
  2. CentOS7发布ASP.NET Core网站
  3. servlet-servletContext简述
  4. 程序员鼓励师是什么?
  5. 淡定的写代码,淡定的人生
  6. caffe学习日记--Lesson2:再看caffe的安装和使用、学习过程
  7. CodeFights Python 编程实训
  8. Git学习(一)本地操作
  9. 面试题之求二叉树的深度
  10. php 表别名,MySQL和PHP – 不是唯一的表/别名