Summary of Linux Host Hardware Information Collection Commands

In the operation and maintenance process of OpenStack, Kubernetes, physical machines, or virtualization platforms, the ability to quickly collect host hardware information is of great significance for problem diagnosis. Mastering the knowledge in this article indicates that you are an experienced engineer.

๐Ÿง  1. Basic Information Identification

Function Command
View Product Model <span><span>cat /sys/class/dmi/id/product_name</span></span>
View Vendor <span><span>cat /sys/class/dmi/id/sys_vendor</span></span>
View Motherboard Model <span><span>cat /sys/class/dmi/id/board_name</span></span>
View Serial Number <span><span>cat /sys/class/dmi/id/product_serial</span></span>
View UUID <span><span>dmidecode -s system-uuid</span></span>

๐Ÿ“‹ Example Output

[root@reg ]# cat /sys/class/dmi/id/product_name
VMware Virtual Platform  #esxi virtualization platform
#Other platforms
KVM Virtual Machine  #kvm virtual machine
Alibaba Cloud    #Alibaba Cloud host

This information can help you determine which virtualization platform the host is running on.

โš™๏ธ 2. CPU Information

๐Ÿ”น View CPU Architecture and Cores

lscpu

๐Ÿ”น Determine if virtualization or AVX instruction set is supported

lscpu | grep -E 'vmx|svm|avx'

๐Ÿ”น View the number of physical CPUs and cores

cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
cat /proc/cpuinfo | grep "cpu cores" | uniq

This information is commonly used for

  • โ€ข Analyzing performance bottlenecks
  • โ€ข Determining support for KVM / Docker virtualization
  • โ€ข Verifying cloud host CPU allocation strategy

๐Ÿ’พ 3. Disk and Storage Information

๐Ÿ”น View Disk Type and Serial Number

lsblk -o NAME,TYPE,SIZE,MODEL,ROTA,SERIAL,MOUNTPOINT

<span><span>ROTA=0</span></span> โ†’ SSD<span><span>ROTA=1</span></span> โ†’ HDD (Mechanical Disk)

๐Ÿ”น View Detailed Disk Attributes

udevadm info --query=all --name=/dev/sda | grep -E 'ID_MODEL|ID_SERIAL|ROTATION'

๐Ÿ”น NVMe SSD Viewing Method

nvme list

๐Ÿ‘‰ These commands can help you determine whether the disk is solid-state, whether the model is consistent, and whether there are virtual disks.

๐Ÿง  4. Memory and Slot Information

๐Ÿ”น View Memory Usage

free -h

๐Ÿ”น View the size, slot, type, and speed of each memory stick

dmidecode -t memory | grep -E 'Size|Locator|Type|Speed'

๐Ÿ’ก This can quickly determine which slots are empty and which memory frequencies do not match, making it a powerful tool for troubleshooting hardware issues.

๐ŸŒ 5. Network and Virtual Network Card Identification

๐Ÿ”น View All Network Interfaces

DEVICE      TYPE      STATE         CONNECTION 
dq          bridge    connected      dq         
enP1s16f1   ethernet  connected      enP1s16f1  
virbr0      bridge    connected (external)  virbr0     
enP1s16f0   ethernet  connected      enP1s16f0  
vnet0       tun       connected (external)  vnet0      
vnet1       tun       connected (external)  vnet1      
vnet2       tun       connected (external)  vnet2      
enP2s1f0    ethernet  disconnected    --         
enP2s1f1    ethernet  disconnected    --         
enP2s1f2    ethernet  disconnected    --         
enP2s1f3    ethernet  disconnected    --         
docker0     bridge    unmanaged        --         
lo          loopback  unmanaged        --         
virbr0-nic  tun       unmanaged        --    

๐Ÿ”น Status Explanation:

  • โ€ข dqใ€enP1s16f0/f1: Physically connected, managed by NetworkManager.
  • โ€ข virbr0 / vnet0~2: Created by <span><span>libvirt</span></span> (KVM virtualization), detected by NetworkManager but not managed, status is “connected (external)”.
  • โ€ข docker0: A virtual bridge created by Docker. NetworkManager does not manage it by default, as it may interfere with container networking.
  • โ€ข lo (loopback) and virbr0-nic: Also unmanaged devices, used by the system itself or libvirt.
  • โ€ข enP2s1f0~3: Physical network cards, currently not activated, meaning no network cable is connected.

๐Ÿ”น View All Network Interfaces

ip -br link

๐Ÿ”น View Detailed Parameters of a Single Network Card

ethtool eth0

In a Kubernetes environment, common network card descriptions are as follows

Network Card Description
<span><span>cni0</span></span> Container Bridge Network Card (internal communication within containers)
<span><span>flannel.1</span></span> Flannel VXLAN Tunnel Interface (cross-node communication)
<span><span>cbr0</span></span> Kubernetes Bridge (common in older versions)

๐Ÿงพ 6. System and BIOS Information

๐Ÿ”น View System Version

cat /etc/os-release

๐Ÿ”น View Kernel Version

uname -r

๐Ÿ”น View BIOS Information

dmidecode -s bios-version
dmidecode -s bios-release-date

๐Ÿ” 7. Unique Machine Identification (Identity Recognition)

๐Ÿ”น System Unique Identifier

cat /etc/machine-id

๐Ÿ”น System UUID

dmidecode -s system-uuid

๐Ÿ’ก This information is commonly used for

  • โ€ข Host Registration
  • โ€ข Software Licensing
  • โ€ข CMDB Asset Unique Identification

๐Ÿงฉ 8. One-Key Information Collection Script

๐Ÿ“ฆ The following script can automatically collect key system information

#!/bin/bash
echo"==== Basic Information ===="
cat /sys/class/dmi/id/{sys_vendor,product_name,product_serial} 2>/dev/null

echo"==== CPU ===="
lscpu | grep -E 'Model name|Socket|Thread|Core|Vendor|Flags'

echo"==== Disk ===="
lsblk -o NAME,SIZE,ROTA,MODEL,SERIAL | grep -v loop

echo"==== Memory ===="
dmidecode -t memory | grep -E 'Size|Locator|Type|Speed' | grep -v "No Module Installed"

echo"==== Network Card ===="
ip -br link

echo"==== System ===="
cat /etc/os-release | grep PRETTY_NAME
uname -r
cat /etc/machine-id

More exciting content!

Leave a Comment