How to view CPU count under Linux system

Source: Internet
Author: User

To view the number of logical CPUs:
#cat /proc/cpuinfo |grep "processor"|sort -u|wc -l24
To view the number of physical CPUs:
#grep "physical id" /proc/cpuinfo|sort -u|wc -l                   2#grep "physical id" /proc/cpuinfo|sort -u                   physical id     : 0physical id     : 1
To view the number of cores per physical CPU:
#grep "cpu cores" /proc/cpuinfo|uniqcpu cores       : 6
Number of logical CPUs on each physical CPU:
#grep "siblings" /proc/cpuinfo|uniqsiblings        : 12
Determine if hyper-threading is turned on:

If the "Physical ID" and "core ID" of multiple logical CPUs are the same, the description turns on Hyper-threading, or in other words

逻辑CPU个数 > 物理CPU个数 * CPU内核数   开启了超线程逻辑CPU个数 = 物理CPU个数 * CPU内核数   没有开启超线程
Check all information at once:
#!/bin/bashphysicalNumber=0coreNumber=0logicalNumber=0HTNumber=0logicalNumber=$(grep "processor" /proc/cpuinfo|sort -u|wc -l)physicalNumber=$(grep "physical id" /proc/cpuinfo|sort -u|wc -l)coreNumber=$(grep "cpu cores" /proc/cpuinfo|uniq|awk -F‘:‘ ‘{print $2}‘|xargs)HTNumber=$((logicalNumber / (physicalNumber * coreNumber)))echo "****** CPU Information ******"echo "Logical CPU Number  : ${logicalNumber}"echo "Physical CPU Number : ${physicalNumber}"echo "CPU Core Number     : ${coreNumber}"echo "HT Number           : ${HTNumber}"echo "*****************************"
Execution Result:
#./cpuinfo  ****** CPU Information ******Logical CPU Number  : 24Physical CPU Number : 2CPU Core Number     : 6HT Number           : 2*****************************

How to view CPU count under Linux system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.