Linux-Fu Part 3 :: Determining physical CPU and core count

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:

Run:

cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l

Example:

[root@deadbeef ~]# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l

Output:

1

The value of 1 here denotes that there is one physical cpu.

Determining cores per CPU:

Run:

cat /proc/cpuinfo | grep "cpu cores" | uniq

Example:

[root@deadbeef ~]# cat /proc/cpuinfo | grep "cpu cores" | uniq

Output:

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).

Advertisements

One thought on “Linux-Fu Part 3 :: Determining physical CPU and core count

  1. Pingback: OSX :: CPU & Core Counting « radfest

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s