find the number of CPU cores on Linux

Multi-core CPU processors are common nowadays, including dual-core processors (e.g., Intel Core Duo), quad-core processors (e.g., Intel Core i5), and hexa-core processors (e.g., AMD Phenom II X6). Also, many server-grade physical machines are equipped with more than one CPU processor.

To find the number of physical CPUs:

$ cat /proc/cpuinfo | grep “^physical id” | sort | uniq | wc -l
2

To find the number of cores per CPU:

$ cat /proc/cpuinfo | grep “^cpu cores” | uniq
cpu cores       : 4

The total number of processors available is the number of physical CPUs multiplied by the number of cores per CPU.

To find the total number of processors:

$ cat /proc/cpuinfo | grep “^processor” | wc -l
16

Note that Intel Xeon 5600 series processors have Intel Hyper-Threading capability. So each core shows up as “two” processors in Linux, and thus the total processor count seen by Linux is 16 (= 2 x 4 x 2).

 

Related Posts

  • 36
    What is a process? Except the kernel, Everything on a Linux system runs in the context of a process. Process can be loosely defined as a running program. Every process on a Linux system has a unique Process ID (PID). Users and programs use this PID to communicate with the…
    Tags: linux
  • 36
    The lscpu command is CPU architecture information helper and can be found under Fedora Linux / RHEL / CentOS v6+ / Debian Linux v6+ and many other latest distro includes this command. Warning : lscput command has bug and sometimes in Xen Dom0 kernel reports wrong data. So please use…
    Tags: cpu, linux, core, /proc/cpuinfo
%d bloggers like this: