Linux

How to determine number of CPUs on Linux using command line

 

I am a new Linux system admin. How do I obtain the number of CPUs and cores in the Linux system from the command line? How do I determine the number of CPUs on Linux?

A CPU is an acronym for the central processing unit. It is an essential part of a computer. The CPU sends signals that control the other part of the Linux server. You can call it as the brain of your computer. This page show how to find out number of CPUs on Linux using command line.

 

 

Command to determine number of CPUs on Linux

The procedure is as follows:

  1. Log in into your Linux desktop
  2. Open the terminal application on Linux
  3. For remote server run ssh [email protected]
  4. To get CPU information type lscpu that display information about the CPU architecture of Linux including installed CPUs

Let us see all examples in details.

Linux determine number of CPUs using the lscpu command

Simply type the following command:
lscpu
Linux determine number of CPUs using lscpu command
From above output it is clear that:

  • Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz – Model name (CPU name/make)
  • 1 – Socket(s) i.e. number of CPUs
  • 4 – Cores per socket
  • 2 – Thread(s) per core
  • 8 – 8 logical core (Hyper-threading) [cores per socket * threads per core]

How do I display the number of processing units available?

You can show the number of processing units available to the current process including all installed processors:
nproc --all
Sample outputs:

Another option to obtain the number of CPUs/cores in Linux

You can run the following command too:
getconf _NPROCESSORS_ONLN
Sample outputs:

Say hello to /proc/cpuinfo

Use the cat command to see info about your CPU and system architecture dependent items, for each supported architecture a different list:
cat /proc/cpuinfo
You can use the combination of grep command and wc command as follows to print

Sample outputs:

The output from /proc/cpuinfo can be difficult to phrase. Therefore, it is better to use the lscpu command:
lscpu
Sample outputs:

Conclusion

Explains how to determine the number of CPUs, cores, and threads on Linux using lscpu and other commands. This information is useful for licensing third-party apps that work per socket or core.

 

Facebook Comments

Tags
Show More

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button