如何在Linux上使用dmidecode命令获取硬件信息

每个Linux用户都应该了解Linux硬件的基本配置。市场上有很多工具可以在Linux中获取硬件信息。Dmidecode是用于以人类可读格式转储计算机的DMI(桌面管理接口)表内容的工具。该表包含系统硬件组件的描述以及其他有用的信息,例如序列号和BIOS版本。本文介绍了“如何在Linux上使用Dmidecode命令获取硬件信息”

安装Dmidecode

要安装Dmidecode,请使用以下命令-

$ sudo apt-get install dmidecode

样本输出应如下所示–

Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
dmidecode
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 45.9 kB of archives.
After this operation, 196 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu/ trusty/main dmidecode amd64 2.12-2 [45.9 kB]
Fetched 45.9 kB in 0s (52.2 kB/s)
Selecting previously unselected package dmidecode.
(Reading database ... 218604 files and directories currently installed.)
Preparing to unpack .../dmidecode_2.12-2_amd64.deb ...
Unpacking dmidecode (2.12-2) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up dmidecode (2.12-2) ...
.................................

使用Dmidecode工具

要使用Dmidecode工具,请使用以下命令-

$ sudo dmidecode

样本输出应如下所示–

# dmidecode 2.12
# SMBIOS entry point at 0xcbf6b498
SMBIOS 2.8 present.
45 structures occupying 2096 bytes.
Table at 0xCBD68018.
Handle 0xDA00, DMI type 218, 251 bytes
OEM-specific Type
   Header and Data:
      DA FB 00 DA B2 00 0D 5F 0F 37 40 7D 00 00 00 00
      00 7E 00 01 00 00 00 75 01 01 80 01 00 76 01 02
      80 01 00 2D 01 03 80 01 00 2E 01 04 80 00 00 4F
      02 05 80 01 00 50 02 06 80 00 00 E2 01 02 00 00
      00 E1 01 02 00 01 00 E3 01 02 00 02 00 58 02 20
      80 00 00 57 02 20 80 01 00 9C 00 03 00 01 00 9B
      00 03 00 00 00 8A 01 04 00 01 00 89 01 04 00 00
      00 7F 01 05 00 00 00 80 01 05 00 01 00 53 01 06
      00 00 00 52 01 06 00 01 00 7B 01 07 00 00 00 7C
      01 07 00 01 00 94 01 08 00 00 00 93 01 08 00 01
      00 7D 00 09 00 00 00 2D 00 0A 00 01 00 2E 00 0A
      00 00 00 6E 00 0B 00 00 00 95 00 0C 00 01 00 96
      00 0C 00 00 00 2F 02 0D 00 01 00 30 02 0D 00 00
      00 4B 01 0E 00 01 00 4A 01 0E 00 00 00 37 01 0F
      00 00 00 38 01 0F 00 01 00 39 01 0F 00 02 00 2E
      02 07 80 01 00 FF FF 00 00 00 00
........................

获取有关Dmidecode的更多信息

要获取有关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
-V, --version           Display the version and exit

要获取有关每种设备配置的更多信息,请使用以下命令行语法–

$ sudo dmidecode -t Device name

例如,要获取BIOS信息,请使用以下命令-

$ sudo dmidecode -t bios

样本输出应如下所示:

# dmidecode 2.12
# SMBIOS entry point at 0xcbf6b498
SMBIOS 2.8 present.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
   Vendor: Dell Inc.
   Version: A04
   Release Date: 08/05/2014
   Address: 0xF0000
   Runtime Size: 64 kB
   ROM Size: 2048 kB
   Characteristics:
      MCA is supported
      PCI is supported
      BIOS is upgradeable
      BIOS shadowing is allowed
      ESCD support is available
      Boot from CD is supported
      Selectable boot is supported
      BIOS ROM is socketed
      EDD is supported
      5.25"/1.2 MB floppy services are supported (int 13h)
      3.5"/720 kB floppy services are supported (int 13h)
      3.5"/2.88 MB floppy services are supported (int 13h)
      Print screen service is supported (int 5h)
      8042 keyboard services are supported (int 9h)
      Serial services are supported (int 14h)
      Printer services are supported (int 17h)
      CGA/mono video services are supported (int 10h)
      ACPI is supported
      USB legacy is supported
      ATAPI Zip drive boot is supported
      BIOS boot specification is supported
      Targeted content distribution is supported
      UEFI is supported
   BIOS Revision: 0.4
   Firmware Revision: 0.4
.............

要获取系统信息,请使用以下命令–

$ sudo dmidecode -t memory

样本输出应如下所示–

# dmidecode 2.12
# SMBIOS entry point at 0xcbf6b498
SMBIOS 2.8 present.
Handle 0x0017, DMI type 17, 40 bytes
Memory Device
   Array Handle: 0x0007
   Error Information Handle: Not Provided
   Total Width: 64 bits
   Data Width: 64 bits
   Size: 8192 MB
   Form Factor: SODIMM
   Set: None
   Locator: DIMM_A
   Bank Locator: Bank 0
   Type: DDR3
   Type Detail: Synchronous
   Speed: 1600 MHz
   Manufacturer: Transcend
   Serial Number: 000A7430
   Asset Tag: 54150300
   Part Number: TS1GSK64W6H
   Rank: 2
   Configured Clock Speed: 1600 MHz
   Minimum voltage: 1.350 V
   Maximum voltage: 1.500 V
   Configured voltage: 1.350 V
......................................

要获取处理器信息,请使用以下命令–

$ sudo dmidecode -t processor

样本输出应如下所示–

# dmidecode 2.12
# SMBIOS entry point at 0xcbf6b498
SMBIOS 2.8 present.
Handle 0x0024, DMI type 4, 42 bytes
Processor Information
   Socket Designation: SOCKET 0
   Type: Central Processor
   Family: Core i5
   Manufacturer: Intel
   ID: 51 06 04 00 FF FB EB BF
   Signature: Type 0, Family 6, Model 69, Stepping 1
   Flags:
      FPU (Floating-point unit on-chip)
      VME (Virtual mode extension)
      DE (Debugging extension)
      PSE (Page size extension)
      TSC (Time stamp counter)
      MSR (Model specific registers)
      PAE (Physical address extension)
      MCE (Machine check exception)
      CX8 (CMPXCHG8 instruction supported)
      APIC (On-chip APIC hardware supported)
      SEP (Fast system call)
      MTRR (Memory type range registers)
      PGE (Page global enable)
      MCA (Machine check architecture)
      CMOV (Conditional move instruction supported)
      PAT (Page attribute table)
      PSE-36 (36-bit page size extension)
      CLFSH (CLFLUSH instruction supported)
      DS (Debug store)
      ACPI (ACPI supported)
      MMX (MMX technology supported)
      FXSR (FXSAVE and FXSTOR instructions supported)
      SSE (Streaming SIMD extensions)
      SSE2 (Streaming SIMD extensions 2)
      SS (Self-snoop)
      HTT (Multi-threading)
      TM (Thermal monitor supported)
      PBE (Pending break enabled)
   Version: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
.............................

要获取缓存信息,请使用以下命令–

$ sudo dmidecode -t cache

样本输出应如下所示–

# dmidecode 2.12
# SMBIOS entry point at 0xcbf6b498
SMBIOS 2.8 present.
Handle 0x0006, DMI type 7, 19 bytes
Cache Information
   Socket Designation: CPU Internal L3
   Configuration: Enabled, Not Socketed, Level 3
   Operational Mode: Write Back
   Location: Internal
   Installed Size: 3072 kB
   Maximum Size: 3072 kB
   Supported SRAM Types:
   Unknown
   Installed SRAM Type: Unknown
   Speed: Unknown
   Error Correction Type: Single-bit ECC
   System Type: Unified
   Associativity: 12-way Set-associative
...............................................

要获取端口连接器信息,请使用以下命令–

$ sudo dmidecode port connector

样本输出应如下所示–

# dmidecode 2.12
# SMBIOS entry point at 0xcbf6b498
SMBIOS 2.8 present.
45 structures occupying 2096 bytes.
Table at 0xCBD68018.
Handle 0xDA00, DMI type 218, 251 bytes
OEM-specific Type
   Header and Data:
      DA FB 00 DA B2 00 0D 5F 0F 37 40 7D 00 00 00 00
      00 7E 00 01 00 00 00 75 01 01 80 01 00 76 01 02
      80 01 00 2D 01 03 80 01 00 2E 01 04 80 00 00 4F
      02 05 80 01 00 50 02 06 80 00 00 E2 01 02 00 00
      00 E1 01 02 00 01 00 E3 01 02 00 02 00 58 02 20
      80 00 00 57 02 20 80 01 00 9C 00 03 00 01 00 9B
      00 03 00 00 00 8A 01 04 00 01 00 89 01 04 00 00
      00 7F 01 05 00 00 00 80 01 05 00 01 00 53 01 06
      00 00 00 52 01 06 00 01 00 7B 01 07 00 00 00 7C
      01 07 00 01 00 94 01 08 00 00 00 93 01 08 00 01
      00 7D 00 09 00 00 00 2D 00 0A 00 01 00 2E 00 0A
      00 00 00 6E 00 0B 00 00 00 95 00 0C 00 01 00 96
      00 0C 00 00 00 2F 02 0D 00 01 00 30 02 0D 00 00
      00 4B 01 0E 00 01 00 4A 01 0E 00 00 00 37 01 0F
      00 00 00 38 01 0F 00 01 00 39 01 0F 00 02 00 2E
      02 07 80 01 00 FF FF 00 00 00 00
................................................

恭喜你!现在,您知道“如何在Linux上使用Dmidecode命令获取硬件信息”。在我们的下一篇Linux文章中,我们将详细了解这些类型的命令。继续阅读!