Linux查看硬件及系统信息

1. 查看操作系统信息

1.1. cat /etc/os-release系统版本信息

1.2. cat /etc/system-release系统版本及描述信息

1.3. uname -a查看系统版本号

2. BIOS信息

$ dmidecode -t -help
Invalid type keyword: -help
Valid type keywords are:
  bios
  system
  baseboard
  chassis
  processor
  memory
  cache
  connector
  slot

2.1. dmidecode -t bios 查看BIOS信息

$ # dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.2.1 present.
# SMBIOS implementations newer than version 3.2.0 are not
# fully supported by this version of dmidecode.

Handle 0x0000, DMI type 0, 26 bytes
BIOS Information
    Vendor: American Megatrends Inc.
    Version: 3.4
    Release Date: 06/22/2021
    Address: 0xF0000
    Runtime Size: 64 kB
    ROM Size: 32 MB
    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.14

Handle 0x0072, 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

2.2. dmidecode -q 可以查看所有的硬件信息

$ dmidecode -q | more

2.3. dmidecode -t baseboard 查看网卡硬件信息

$ dmidecode -t baseboard |grep Ethernet -C 5

3. cpu

3.1. lscpu:查看cpu的统计信息

$ lscpu

Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   46 bits physical, 48 bits virtual
CPU(s):                          64
On-line CPU(s) list:             0-63
Thread(s) per core:              2
Core(s) per socket:              16
Socket(s):                       2
NUMA node(s):                    2
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           85
Model name:                      Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz
Stepping:                        7
CPU MHz:                         2299.912
CPU max MHz:                     2300.0000
CPU min MHz:                     1000.0000
BogoMIPS:                        4600.00
Virtualization:                  VT-x
L1d cache:                       1 MiB
L1i cache:                       1 MiB
L2 cache:                        32 MiB
L3 cache:                        44 MiB
NUMA node0 CPU(s):               0-15,32-47
NUMA node1 CPU(s):               16-31,48-63
Vulnerability Itlb multihit:     KVM: Mitigation: Split huge pages
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Enhanced IBRS, IBPB conditional, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Mitigation; TSX disabled

3.2. cat /proc/cpuinfo查看每个cpu的信息或型号

$ cat /proc/cpuinfo | more
# 此处显示0 号cpu核心的相关参数
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 85
model name  : Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz
stepping    : 7
microcode   : 0x5003003
cpu MHz     : 2300.003
cache size  : 22528 KB
physical id : 0
siblings    : 32
core id     : 0
cpu cores   : 16
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 22
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb r
dtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3
 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat
_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 sme
p bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc 
cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
bugs        : spectre_v1 spectre_v2 spec_store_bypass swapgs taa itlb_multihit
bogomips    : 4600.00
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

4. 内存

4.1. free -m 查看内存的概要信息,单位是M

$ free -m
              total        used        free      shared  buff/cache   available
Mem:         514140      211910      294879        4140        7350      295103
Swap:             0           0           0

4.2. cat /proc/meminfo 查看内存的详细使用

$ cat /proc/meminfo | more

MemTotal:       526479604 kB
MemFree:        301965364 kB
MemAvailable:   302194936 kB
Buffers:               0 kB
Cached:          7376904 kB
SwapCached:            0 kB
Active:          3380068 kB
Inactive:        6894924 kB
Active(anon):    2970060 kB
Inactive(anon):  4041736 kB
Active(file):     410008 kB
Inactive(file):  2853188 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:               100 kB
Writeback:             0 kB
AnonPages:       2852980 kB
Mapped:           453076 kB
Shmem:           4239944 kB
...

4.3. dmidecode -t memory 查看内存的硬件信息

$ dmidecode -t memory | more

# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.2.1 present.
# SMBIOS implementations newer than version 3.2.0 are not
# fully supported by this version of dmidecode.

Handle 0x000F, DMI type 16, 23 bytes
Physical Memory Array
    Location: System Board Or Motherboard
    Use: System Memory
    Error Correction Type: Single-bit ECC
    Maximum Capacity: 5 TB
    Error Information Handle: Not Provided
    Number Of Devices: 16

Handle 0x0010, DMI type 17, 84 bytes
Memory Device
    Array Handle: 0x000F
    Error Information Handle: Not Provided
    Total Width: 72 bits
    Data Width: 64 bits
    Size: 32 GB
    Form Factor: DIMM
    Set: None
    Locator: P1-DIMMA1
    Bank Locator: P0_Node0_Channel0_Dimm0
    Type: DDR4
    Type Detail: Synchronous Registered (Buffered)
    Speed: 2666 MT/s
    Manufacturer: Micron
    Serial Number: 21D73388
    Asset Tag: P1-DIMMA1_AssetTag (Date:19/19)

5. 磁盘

5.1. lsblk 查看硬盘和分区分布

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 446.6G  0 disk 
├─sda1   8:1    0    50G  0 part /
└─sda2   8:2    0 396.6G  0 part /var

5.2. fdisk -l 查看硬盘和分区的详细信息

$ fdisk -l

Disk /dev/sda: 446.64 GiB, 479559942144 bytes, 936640512 sectors
Disk model: SMC3108         
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: dos
Disk identifier: 0xca92f92c

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048 104859647 104857600    50G 83 Linux
/dev/sda2       104859648 936640511 831780864 396.6G 83 Linux

6. 网卡

6.1. lspci 显示所有pci设备信息,即主板的硬件槽信息

lspci | grep -i 'eth' 查看网卡硬件信息

$ lspci | grep -i 'eth'

18:00.0 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
18:00.1 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
60:00.0 Ethernet controller: Intel Corporation Ethernet Connection X722 for 1GbE (rev 09)
60:00.1 Ethernet controller: Intel Corporation Ethernet Connection X722 for 1GbE (rev 09)
86:00.0 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
86:00.1 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)

6.2. ifconfig -a 查看所有的网络接口

$ ifconfig -a
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet6 fe80::ae1f:6bff:feb5:be46  prefixlen 64  scopeid 0x20<link>
        ether ac:1f:6b:b5:be:46  txqueuelen 1000  (Ethernet)
        RX packets 3609823644  bytes 399690782877 (372.2 GiB)
        RX errors 0  dropped 13  overruns 0  frame 0
        TX packets 2029569161  bytes 2664089647822 (2.4 TiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

bond0.150: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.8.73.66  netmask 255.255.252.0  broadcast 10.8.75.255
        inet6 fe80::ae1f:6bff:feb5:be46  prefixlen 64  scopeid 0x20<link>
        ether ac:1f:6b:b5:be:46  txqueuelen 1000  (Ethernet)
        RX packets 1979234396  bytes 271768015782 (253.1 GiB)
        RX errors 0  dropped 203  overruns 0  frame 0
        TX packets 368470816  bytes 2554795424044 (2.3 TiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

6.3. ip link show 查看网络接口

$ ip link show bond0
8: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether ac:1f:6b:b5:be:46 brd ff:ff:ff:ff:ff:ff

6.4. 查看网卡的绑卡和驱动信息

$ ethtool -i eno1
driver: i40e
version: 2.3.2-k
firmware-version: 3.33 0x80000e48 1.1876.0
expansion-rom-version: 
bus-info: 0000:60:00.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: yes

6.5. cat /proc/net/dev 查看网络配置信息

6.6. ethtool 名称 查看某个网络的详细信息,如ens33

$ ethtool eno1
Settings for eno1:
    Supported ports: [ TP ]
    Supported link modes:   1000baseT/Full 
    Supported pause frame use: Symmetric
    Supports auto-negotiation: Yes
    Supported FEC modes: Not reported
    Advertised link modes:  1000baseT/Full 
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Advertised FEC modes: Not reported
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: Unknown
    Supports Wake-on: g
    Wake-on: g
    Current message level: 0x00000007 (7)
                   drv probe link
    Link detected: yes

发表评论

邮箱地址不会被公开。 必填项已用*标注