Categories: Ubuntu

How to Find the Number of Cores in Ubuntu

Linux administrators often need to know the number of cores while managing the Linux servers and assigning various tasks to multiple server machines. Initially, Computer systems come with single-core CPUs, but nowadays, we have multi-core CPUs to increase performance. This post will provide numerous methods and commands to find the number of cores in the Ubuntu 20.04 LTS system.

  • Using the “lscpu” command
  • Using the “/proc/cpuinfo” file
  • Using the “nproc” command

Method 1: Finding the number of cores in Ubuntu using the “lscpu” command

The ‘lscpu’ command provides all the information related to the CPU Architecture.

$ lscpu
Sponsored

The above command will show all the information related to the CPU, like CPU Architecture, the number of CPU cores, threads per core, etc.

To filter out the CPU information only, use the ‘lscpu’ command with the ‘egrep’ command like this:

$ lscpu | egrep ‘CPU(s)’

As you can see in the screenshot attached above, the lines which contain the string “CPU” are shown as an output to the command mentioned above:

This ‘lscpu’ command collects all the information from the ‘/proc/cpuinfo’ file and sysfs, so this means we can directly get the CPU-related information from the ‘/proc/cpuinfo’ file.

Method 2: Finding the number of cores in Ubuntu using the “/proc/cpuinfo” file

As the name of ‘/proc/cpuinfo’ is saying, it is a file that contains the information of CPU, and we can easily view all the information of this file using the cat command:

Sponsored
$ cat /proc/cpuinfo

From this whole bunch of information, we can filter out the information and get the exact number of cores by combining the cat, grep, and wc command as shown in the below-given command:

$ cat /proc/cpuinfo | grep processor | wc -l

You can see, it has shown only the number of cores.

Method 3: Finding the number of cores in Ubuntu using the “nproc” command

Instead of using the ‘grep’ command to filter out the number of cores from the ‘/proc/cpuinfo’ file, there is a simple command known as ‘nproc’ for getting the number of cores only:

$ nproc

As you can witness in the output of the above command, it also has printed out the number of cores as we desired.

Conclusion

This post contains three easy yet profound methods to find the number of cores and other CPU-related information in the Ubuntu 20.04 LTS Operating system. Using any of the above-given methods, finding the number of cores is no longer difficult.

Ubuntu Server Admin

Recent Posts

Canonical Releases Ubuntu 25.04 Plucky Puffin

The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…

2 days ago

Ubuntu 25.04 (Plucky Puffin) Released

Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…

3 days ago

Extended Security Maintenance for Ubuntu 20.04 (Focal Fossa) begins May 29, 2025

Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…

3 days ago

Ubuntu 20.04 LTS End Of Life – activate ESM to keep your fleet of devices secure and operational

Focal Fossa will reach the End of Standard Support in May 2025, also known as…

4 days ago

Ubuntu MATE 25.04 Release Notes

Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

4 days ago

Ubuntu Weekly Newsletter Issue 887

Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

6 days ago