CPU信息查询方法
在 Centos 中,查询CPU信息非常容易。系统已经自带了了很多工具,可以帮助我们查询硬件信息。下面具体讲解 Centos 下查看 CPU 信息的常用方法。
方法一:使用 lscpu 命令
Lscpu 是一款查看 CPU 信息的命令工具,我们可以使用该命令查看 CPU 型号、数量、核数、线程数、缓存等信息。使用该命令非常简单,只需在终端中输入以下命令:
lscpu
执行命令后,会列出 CPU 的各种信息。例如:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 15
Model: 4
Model name: Intel(R) Pentium(R) 4 CPU 3.20GHz
Stepping: 1
CPU MHz: 3192.809
BogoMIPS: 6385.61
L1d cache: 16K
L2 cache: 2048K
NUMA node0 CPU(s): 0
其中,Architecture 表示 CPU 的架构,CPU(s)表示 CPU 数量,Core(s) per socket 表示每个 CPU 插槽中核心数量,Thread(s) per core 表示每个核心中线程数,L1d cache 表示一级缓存大小,L2 cache 表示二级缓存大小等。
方法二:使用 cat /proc/cpuinfo 命令
除了 lscpu 命令外,我们还可以使用 cat /proc/cpuinfo 命令查看CPU信息。这个命令会输出系统当前运行进程的 CPU 相关信息,其中就包括了 CPU 的型号、频率等相关信息。使用方法如下:
cat /proc/cpuinfo
执行该命令后,系统将输出当前运行进程的 CPU 信息。例如:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 85
model name : Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
stepping : 7
microcode : 0xd6
cpu MHz : 2296.056
cache size : 6144 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
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 rdtscp 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 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt ibrs_legacy stibp_enhanced tsc_ibt intel_ppin ssbd_off ibpb_enhanced tsc_scale arat md_clear flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2
bogomips : 3984.00
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
其中,model name 表示 CPU 的型号,cpu MHz 表示 CPU 的频率,cache size 表示缓存大小等信息。
方法三:使用 Top 命令查看 CPU 使用情况
在 Centos 中,我们还可以使用 top 命令查看 CPU 使用情况。Top 命令可以实时动态地显示系统 CPU 和内存的使用情况。以下是使用方法:
top
执行命令后,会显示类似下面的信息:
top - 22:02:58 up 50 min, 2 users, load average: 0.00, 0.08, 0.13
Tasks: 191 total, 1 running, 190 sleeping, 0 stopped, 0 zombie
%Cpu(s): 1.1 us, 0.4 sy, 0.0 ni, 98.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 7688.7 total, 1192.7 free, 3523.1 used, 2973.0 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 3885.5 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2564 root 20 0 106912 5752 2568 S 2.0 0.1 1:26.83 X
2220 root 20 0 25064 1984 1676 R 0.7 0.0 0:00.09 top
379 root -51 0 0 0 0 S -0.3 0.0 0:00.00 irq/30-radeon
7 root 20 0 0 0 0 S 0.3 0.0 0:01.03 ksoftirqd/1
933 root 20 0 1641916 9760 5016 S 0.3 0.1 0:12.52 systemd-journal
1 root 20 0 168080 5860 3692 S 0.0 0.1 0:08.02 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.03 kthreadd
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:-events
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
其中,%CPU 表示该进程占用 CPU 的百分比,而 CPU(s) 则表示系统的总体 CPU 使用情况。我们可以通过 top 命令来实时监控系统的 CPU 使用情况。
总结
Linux 系统提供了多种查询 CPU 信息的方法,而在 Centos 系统中,使用 lscpu / cat /proc/cpuinfo / top 命令都可以帮助我们查询 CPU 类型、核心数量、缓存、频率以及系统 CPU 使用情况等各种信息,方便我们更好地了解系统硬件的配置。
香港云服务器