Linux lshw和dmidecode查看硬件信息

Dmidecodelshw这两个工具可以查看Linux下有关硬件信息,这些信息包括 BIOS、系统、主板、处理器、内存、缓存等等

Dmidecode

LINUX下直接安装 apt-get install dmidecode
输入 dmidecode –help 查看帮助

Usage: dmidecode [OPTIONS]
Options are:
-d, –dev-mem FILE Read memory from device FILE (default: /dev/mem)
-h, –help Display this help text and exit
-q, –quiet Less verbose output
-s, –string KEYWORD Only display the value of the given DMI string
-t, –type TYPE Only display the entries of given type
-u, –dump Do not decode the entries
–dump-bin FILE Dump the DMI data to a binary file
–from-dump FILE Read the DMI data from a binary file
–no-sysfs Do not attempt to read DMI data from sysfs files
–oem-string N Only display the value of the given OEM string
-V, –version Display the version and exit

0 BIOS
1 System
2 Base Board
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
9 System Slots
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
36 Management Device Threshold Data
37 Memory Channel
38 IPMI Device
39 Power Supply
40 Additional Information
41 Onboard Device

1.输入 dmidecode -t 列出关键字

dmidecode: option requires an argument – ‘t’
Type number or keyword expected
Valid type keywords are:

bios
system
baseboard
chassis
processor
memory
cache
connector
slot

然后在 dmidecode -t systemdmidecode -t 1 输出

# dmidecode 3.1
Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.

Handle 0x0001, DMI type 1, 27 bytes
System Information
Manufacturer: LENOVO
Product Name: 33661R8
Version: ThinkPad Edge E530c
Serial Number: MP43X9V
……

2.dmidecode -s

dmidecode: option requires an argument – ‘s’
String keyword expected
Valid string keywords are:
bios-vendor
bios-version
bios-release-date
system-manufacturer
system-product-name
system-version
system-serial-number
system-uuid
baseboard-manufacturer
baseboard-product-name
baseboard-version
baseboard-serial-number
baseboard-asset-tag
chassis-manufacturer
chassis-type
chassis-version
chassis-serial-number
chassis-asset-tag
processor-family
processor-manufacturer
processor-version
processor-frequency

dmidecode -s system-version 输出

ThinkPad Edge E530c

lshw(Hardware Lister)

安装:apt-get install lshw
lshw 比较简单 lshw –help

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

1.把信息保存为HTML/XML格式文本

lshw -html > my.html
lshw -xml > my.html

2.显示设备列表,输出包括设备路径(path)、类别(class)以及简单描述 lshw -short

H/W path Device Class Description
……

3.显示指定类别的设备 lshw -C xxxx,其中 xxxx 就是 lshw -short 中的 Class 字段.如 lshw -C disk

*-disk
description: ATA Disk
product: WDC WD5000LPVT-0
vendor: Western Digital
……
*-cdrom
……

例如: lshw -C system|grep version 输出

version: ThinkPad Edge E530c


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!