With multicore CPUs these days it’s becoming easier for SysAdmins and users to be confused with what’s actually configured within a system.
We sometimes ask these sorts of questions:
1. How many physical CPUs does this system have?
2. How many cores does this system have on each CPU?
Rather than parsing through the /var/log/dmesg file or the /proc/cpuinfo file. We can cat and grep against the cpuinfo file with some simple commands to see what we need.
Determining physical CPU count:
cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
[root@deadbeef ~]# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
The value of 1 here denotes that there is one physical cpu.
Determining cores per CPU:
cat /proc/cpuinfo | grep "cpu cores" | uniq
[root@deadbeef ~]# cat /proc/cpuinfo | grep "cpu cores" | uniq
cpu cores: 4
The value of 4 here denotes that each physical CPU has 4 cores (Based on these example commands, this hypothetical deadbeef system has 1 physical cpu w/ 4 cores).