nproc
Linux · Processes · reference only
What it does
Prints the number of processing units (CPUs) available to the current process.
Syntax
nproc [opciones]
Options and parameters
--allPrints all installed CPUs, even if they are not available to the process.
--ignore=NSubtracts N CPUs from the result.
--helpShows help and exits.
--versionShows the version and exits.
Usage examples
nprocShows how many CPUs the current process can use.
nproc --allShows all the CPUs of the machine.
nproc --ignore=1Leaves one CPU free for the rest of the system.
make -j"$(nproc)"Compiles using as many parallel jobs as there are CPUs.
Notes and common mistakes
- The result counts logical threads: with hyper-threading it can be twice the physical cores.