Linux 系統主要透過指令查看硬體資訊,不像 Windows 那麼直觀。本文整理了查看 CPU、記憶體、磁碟、網卡、PCI 裝置、BIOS 等關鍵硬體資訊的實用指令,並附上實際輸出範例,方便系統管理員快速診斷硬體狀態。
$ lscpu
Architecture: i686
CPU op-mode(s): 32-bit, 64-bit
CPU(s): 4
Thread(s) per core: 1
Core(s) per socket: 4
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) i5-2320 CPU @ 3.00GHz
Virtualization: VT-x
L3 cache: 6144K
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
model name : Intel(R) Core(TM) i5-2320 CPU @ 3.00GHz
cpu MHz : 1600.000
cache size : 6144 KB
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 rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer aes xsave avx lahf_lm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid

$ free -m
total used free shared buff/cache available
Mem: 3926 3651 274 0 12 404
Swap: 9536 31 9505
$ cat /proc/meminfo
MemTotal: 4020868 kB
MemFree: 230884 kB
Buffers: 7600 kB
Cached: 454772 kB
SwapTotal: 9765888 kB
SwapFree: 9734524 kB
# dmidecode -t memory
Handle 0x0008, DMI type 16, 23 bytes
Physical Memory Array
Location: System Board Or Motherboard
Maximum Capacity: 32 GB
Handle 0x000A, DMI type 17, 34 bytes
Memory Device
Size: 4096 MB
Type: DDR3
Speed: 1600 MHz
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 9.3G 0 part [SWAP]
├─sda3 8:3 0 74.5G 0 part /
└─sda5 8:5 0 111.8G 0 part /home
# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2148351 1073152 83 Linux
/dev/sda2 2148352 21680127 9765888 82 Linux swap
/dev/sda3 21680128 177930239 78125056 83 Linux
# lspci | grep -i eth
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)
# ip link show
1: lo: mtu 65536 qdisc noqueue state UNKNOWN
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
# ethtool eth0
Speed: 1000Mb/s
Duplex: Full
Link detected: yes
Auto-negotiation: on
# lspci
00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller
00:1b.0 Audio device: Intel Corporation Panther Point High Definition Audio Controller
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller
# dmidecode -t bios
BIOS Information
Vendor: American Megatrends Inc.
Version: 4.6.5
Release Date: 04/25/2012
善用上述指令組合,即可全面掌握 Linux 系統硬體配置,無論是伺服器上架驗收、效能調校或故障排查都能得心應手。