How to check how many CPUs are there in Linux system

There are several ways to check the number of CPUs in a Linux system. Here are a few common methods:

  1. Using the “cat” command with the “/proc/cpuinfo” file:
cat /proc/cpuinfo | grep -c processor
  1. Using the “nproc” command:
nproc
  1. Using the “lscpu” command:
lscpu | grep '^CPU(s):' | awk '{print $2}'
  1. Using the “grep” command with the “/proc/cpuinfo” file:
grep -c ^processor /proc/cpuinfo
  1. Using the getconf _NPROCESSORS_ONLN command:
getconf _NPROCESSORS_ONLN

All the above command will give you the number of CPU present in the system. You can also use htop command to check the number of CPU in the system.

Note that the output of the above commands may vary depending on the specific Linux distribution and version you are using.

Leave a Comment