Home  >  Article  >  Operation and Maintenance  >  How to check the number of CPU cores in Linux?

How to check the number of CPU cores in Linux?

青灯夜游
青灯夜游Original
2020-08-20 13:25:0417262browse

In Linux, you can use "cat /proc/cpuinfo | grep "cpu cores" | uniq" to view the number of CPU cores, that is, the number of cores in each physical CPU.

How to check the number of CPU cores in Linux?

Course recommendation: "linux course"

1. Introduction to knowledge points

1. The cpu information is recorded in /proc/cpuinfo.

2. Top in Linux is equivalent to the task manager under the win system, and can also be used to query

3. The total number of CPU cores = the number of physical CPUs * the number of each physical CPU Number of cores

4. Total number of logical CPUs = Number of physical CPUs * Number of cores per physical CPU * Number of hyperthreads

2. Query command

查看CPU信息(型号)
[root@AAA ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
     24         Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz
     
# 查看物理CPU个数
[root@AAA ~]# cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
2

# 查看每个物理CPU中core的个数(即核数)
[root@AAA ~]# cat /proc/cpuinfo| grep "cpu cores"| uniq
cpu cores    : 6

# 查看逻辑CPU的个数
[root@AAA ~]# cat /proc/cpuinfo| grep "processor"| wc -l
24

What do these represent, then please look at the CPU architecture

Multiple physical CPUs, the CPU communicates through the bus, and the efficiency is relatively low, as follows:

How to check the number of CPU cores in Linux?

Multi-core CPU, different cores communicate through L2 cache, storage and peripherals communicate with the CPU through the bus, as follows:

How to check the number of CPU cores in Linux?

Multi-core hyperthreading, each core has Two logical processing units, two cores share the resources of one core, as follows:

How to check the number of CPU cores in Linux?

From the above execution results, it proves that the CPU I am using has 2 * 6 = 12 cores, each core has 2 hyperthreads, so 24 logical cpu.

Related recommendations: "Linux Operation and Maintenance"

The above is the detailed content of How to check the number of CPU cores in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn