linux如何查看服务器中cpu的数量

时间:2019-04-29 03:17:49  来源:igfitidea点击:

如何从命令行获得Linux系统中的cpu和内核数量?
如何确定Linux上的cpu数量?

Linux使用lscpu命令确定cpu的数量

[root@lautturicentos8 ~]# lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              2
On-line CPU(s) list: 0,1
Thread(s) per core:  1
Core(s) per socket:  1
Socket(s):           2
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               42
Model name:          Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz
Stepping:            7
CPU MHz:             2294.785
BogoMIPS:            4589.57
Virtualization:      VT-x
Hypervisor vendor:   VMware
Virtualization type: full
L1d cache:           32K
L1i cache:           32K
L2 cache:            256K
L3 cache:            3072K
NUMA node0 CPU(s):   0,1
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 syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc cpuid aperfmperf pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt xsave avx hypervisor lahf_lm epb pti tpr_shadow vnmi ept vpid xsaveopt dtherm arat pln pts
[root@lautturicentos8 ~]# 

如何查看可用的处理单元数量?

nproc --all

获取CPU数量的另一种方法

getconf _NPROCESSORS_ONLN

使用cpuinfo获取CPU数量

cat /proc/cpuinfo
grep processor /proc/cpuinfo | wc -l ### CPU数
grep '^core id' /proc/cpuinfo | sort -u | wc -l  ### 内核数