Linux查看硬件信息常用命令

1. lscpu

用于查询CPU信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[root@node105 ~]# lscpu 
Architecture: x86_64 #CPU架构
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 20 #逻辑cpu颗数
On-line CPU(s) list: 0-19
Thread(s) per core: 1 #每个CPU插槽核数/每颗物理CPU核数
Core(s) per socket: 10
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel #CPU厂商ID
CPU family: 6
Model: 79
Model name: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
Stepping: 1
CPU MHz: 2095.148 #CPU主频
BogoMIPS: 4190.29
Hypervisor vendor: VMware
Virtualization type: full #CPU支持的虚拟化技术
L1d cache: 32K #一级缓存。cpu的L1数据缓存
L1i cache: 32K #一级缓存,L1指令缓存
L2 cache: 256K #二级缓存
L3 cache: 20480K #三级缓存
NUMA node0 CPU(s): 0-9
NUMA node1 CPU(s): 10-19
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx hypervisor lahf_lm 3dnowprefetch epb cat_l3 cdp_l3 xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts
[root@node105 ~]#

2. lshw

用于显示硬件信息表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 description: Computer
product: 6ffc6a2a-bf81-47f7-aac4-601e5655113f
vendor: QEMU
version: Standard
width: 64 bits
capabilities: smbios-2.8 dmi-2.8 smp vsyscall32
configuration: boot=normal family=Virtual Machine uuid=2A6AFC6F-81BF-F747-AAC4-601E5655113F
*-core
description: Motherboard
physical id: 0
*-firmware
description: BIOS
vendor: SeaBIOS
physical id: 0
version: seabios-1.7.5-11.el7
date: 04/01/2014
size: 96KiB
*-cpu:0
description: CPU
product: Intel(R) Xeon(R) Silver 4114 CPU @ 2.20GHz
vendor: Intel Corp.
vendor_id: GenuineIntel
physical id: 400
bus info: cpu@0
version: RHEL 7.3.0 PC (i440FX + PIIX, 1996)
slot: CPU 0
size: 2GHz
capacity: 2GHz
width: 64 bits
capabilities: 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 ss syscall nx pdpe1gb rdtscp x86-64 con
stant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm
abm 3dnowprefetch fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xge
tbv1 arat
configuration: cores=1 enabledcores=1 threads=1
*-cpu:1
description: CPU
product: Intel(R) Xeon(R) Silver 4114 CPU @ 2.20GHz
vendor: Intel Corp.
vendor_id: GenuineIntel
physical id: 401
bus info: cpu@1
version: RHEL 7.3.0 PC (i440FX + PIIX, 1996)
slot: CPU 1

3. lsblk

用于列出块设备的信息

1
2
3
4
5
[root@xxx ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 400G 0 disk
└─sda1 8:1 0 400G 0 part /
loop0 7:0 0 918M 0 loop /mnt/cdrom

4. lsscsi

用于列出SCSI的设备信息

1
2
[root@xxx ~]# lsscsi
[2:0:0:0] disk QEMU QEMU HARDDISK 2.5+ /dev/sda

5. fdisk

看硬盘和分区的详细信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fdisk -l

磁盘 /dev/sda:429.5 GB, 429496729600 字节,838860800 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000a0d6e

设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 838860766 419429359+ 83 Linux

磁盘 /dev/loop0:962 MB, 962592768 字节,1880064 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x104bed34

设备 Boot Start End Blocks Id System
/dev/loop0p1 * 0 1880063 940032 0 Empty
/dev/loop0p2 440 17847 8704 ef EFI (FAT-12/16/32)

6. ethtool

查看某个网络接口的详细信息,例如eth0的详细参数和指标

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[root@kafka116 ~]# ethtool enp7s0f0          #注意,这里的enp7s0f0是网卡的名称
Settings for enp7s0f0:
Supported ports: [ TP ]
Supported link modes: 100baseT/Full
1000baseT/Full
10000baseT/Full #支持万兆全双工模式
Supported pause frame use: Symmetric
Supports auto-negotiation: Yes #支持自适应模式,一般都支持
Supported FEC modes: Not reported
Advertised link modes: 100baseT/Full
1000baseT/Full
10000baseT/Full
Advertised pause frame use: Symmetric
Advertised auto-negotiation: Yes #默认使用自适应模式
Advertised FEC modes: Not reported
Speed: 10000Mb/s #现在网卡的速度是万兆Mb/s,
Duplex: Full                  #当前是全双工模式
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown
Supports Wake-on: umbg
Wake-on: g
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes #表示有网线连接,和路由是通的,这可以使用“ifconfig”或者“ip a”查看操作系统中网卡的是否是UP状态。
[root@kafka116 ~]#

7. dmidecode

一种可读的方式dump出机器的DMI(Desktop Management Interface)信息。这些信息包括了硬件以及BIOS,既可以得到当前的配置,也可以得到系统支持的最大配置,比如说支持的最大内存数等。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
[root@kafka116 ~]# dmidecode -t bios           #查看bios信息
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 3.0 present.

Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: American Megatrends Inc.
Version: 4.1.16
Release Date: 06/21/2018
Address: 0xF0000
Runtime Size: 64 kB
ROM Size: 8192 kB
Characteristics:
PCI is supported
BIOS is upgradeable
BIOS shadowing is allowed
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)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
ACPI is supported
USB legacy is supported
BIOS boot specification is supported
Targeted content distribution is supported
UEFI is supported
BIOS Revision: 5.6

Handle 0x0066, DMI type 13, 22 bytes
BIOS Language Information
Language Description Format: Long
Installable Languages: 1
en|US|iso8859-1
Currently Installed Language: en|US|iso8859-1