lshw 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

lshw 命令安装:


-bash/zsh: lshw: command not found

# Windows (WSL2)
sudo apt-get update sudo apt-get install lshw

# Debian
apt-get install lshw

# Ubuntu
apt-get install lshw

# Alpine
apk add lshw

# Arch Linux
pacman -S lshw

# Kali Linux
apt-get install lshw

# CentOS
yum install lshw

# Fedora
dnf install lshw

# Raspbian
apt-get install lshw

# Dockerfile
dockerfile.run/lshw

# Docker
docker run cmd.cat/lshw lshw

lshw 命令补充说明:


lshw 是一个用于列出和显示系统硬件信息的命令行工具。它的全称是 list hardware,它可以在 Linux 系统中使用。lshw 命令提供了对计算机硬件的详细信息,包括处理器、内存、硬盘、网络接口、总线信息等的查询。

lshw 命令语法:


lshw [-format] [-options ...]
     lshw -version

     -version        print program version (B.02.18)

lshw 命令选项:


format can be
        -html           output hardware tree as HTML
        -xml            output hardware tree as XML
        -json           output hardware tree as a JSON object
        -short          output hardware paths
        -businfo        output bus information

options can be
        -dump filename  displays output and dump collected information into a file (SQLite database)
        -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

lshw 命令实例:


lshw 启动图形用户界面:

sudo lshw -X

lshw 以表格格式列出所有硬件:

sudo lshw -short

H/W path        Device     Class          Description
=====================================================
                           system         Alibaba Cloud ECS
/0                         bus            Motherboard
/0/0                       memory         96KiB BIOS
/0/400                     processor      Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz
/0/1000                    memory         16GiB System Memory
/0/1000/0                  memory         16GiB DIMM RAM
/0/100                     bridge         440FX - 82441FX PMC [Natoma]
/0/100/1                   bridge         82371SB PIIX3 ISA [Natoma/Triton II]
/0/100/1.1                 storage        82371SB PIIX3 IDE [Natoma/Triton II]
/0/100/1.2                 bus            82371SB PIIX3 USB [Natoma/Triton II]
/0/100/1.2/1    usb1       bus            UHCI Host Controller
/0/100/1.2/1/1             input          QEMU USB Tablet
/0/100/1.3                 bridge         82371AB/EB/MB PIIX4 ACPI
/0/100/2                   display        GD 5446
/0/100/3                   communication  Virtio console
/0/100/3/0                 generic        Virtual I/O device
/0/100/4                   storage        Virtio block device
/0/100/4/0      /dev/vda   disk           42GB Virtual I/O device
/0/100/4/0/1    /dev/vda1  volume         39GiB EXT4 volume
/0/100/5                   storage        Virtio block device
/0/100/5/0      /dev/vdb   disk           536GB Virtual I/O device
/0/100/5/0/1    /dev/vdb1  volume         499GiB Linux filesystem partition
/0/100/6                   network        Virtio network device
/0/100/6/0      eth0       network        Ethernet interface
/0/100/7                   generic        Virtio memory balloon
/0/100/7/0                 generic        Virtual I/O device
/0/100/1f                  bridge         QEMU PCI-PCI bridge
/0/1                       system         PnP device PNP0b00
/0/2                       input          PnP device PNP0303
/0/3                       input          PnP device PNP0f13
/0/4                       storage        PnP device PNP0700
/0/5                       communication  PnP device PNP0501

lshw 以表格格式列出所有磁盘和存储控制器:

sudo lshw -class disk -class storage -short

H/W path        Device     Class          Description
=====================================================
/0/100/1.1                 storage        82371SB PIIX3 IDE [Natoma/Triton II]
/0/100/4                   storage        Virtio block device
/0/100/4/0      /dev/vda   disk           42GB Virtual I/O device
/0/100/5                   storage        Virtio block device
/0/100/5/0      /dev/vdb   disk           536GB Virtual I/O device
/0/4                       storage        PnP device PNP0700

lshw 将所有网络接口保存到 HTML 文件中:

sudo lshw -class network -html > interfaces.html

HTML 报告具体如下:

id:
network
description: Ethernet controller
product: Virtio network device
vendor: Red Hat, Inc
physical id:
6
bus info:
pci@0000:00:06.0
version: 00
width: 64 bits
clock: 33MHz
capabilities: msix bus_master cap_list
configuration:
driver=virtio-pci
latency=0
resources:
irq:0
memory:fe204000-fe204fff
memory:fe205000-fe205fff
id:
virtio3
description: Ethernet interface
physical id:
0
bus info:
virtio@3
logical name:
eth0
serial: 00:16:3e:2c:3f:24
capabilities: ethernet physical
configuration:
broadcast=yes
driver=virtio_net
driverversion=1.0.0
ip=10.2.0.18
link=yes
multicast=yes

lshw 命令扩展阅读:




lshw 命令评论

共收录到 512Linux 命令