How to determine number of CPUs on Linux using command line

You can determine the number of CPUs on a Linux system using the command nproc. This command is part of the GNU Core Utilities and is available on most Linux distributions.

You can also use the command lscpu to get detailed information about the CPUs on your system. This command is part of the lscpu package, which can be installed on most Linux distributions.

For example, to see the number of CPUs on your system, you can use the following command:

nproc

or

lscpu | grep '^CPU(s):' | awk '{print $2}'

You can also use the command cat /proc/cpuinfo | grep processor | wc -l or grep -c ^processor /proc/cpuinfo to check the number of CPUs.

Leave a Comment