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

  • --all

    Prints all installed CPUs, even if they are not available to the process.

  • --ignore=N

    Subtracts N CPUs from the result.

  • --help

    Shows help and exits.

  • --version

    Shows the version and exits.

Usage examples

  • nproc

    Shows how many CPUs the current process can use.

  • nproc --all

    Shows all the CPUs of the machine.

  • nproc --ignore=1

    Leaves 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.

Related commands