nproc

Print the number of available processing units.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

nproc prints the number of CPUs available to the current process (respecting CPU affinity and cgroups). Simpler than parsing lscpu. Useful for setting parallel job counts in scripts and Makefiles.

Common flags
FlagMeaning
--allPrint total number of processors, not just available
Examples
nprocNumber of CPUs available to current process · explain & risk-check →
nproc --allTotal CPU count on the system · explain & risk-check →
make -j$(nproc)Compile using all available CPUs · explain & risk-check →
xargs -P $(nproc)Parallelize to number of CPUs · explain & risk-check →
Pro tip

Use `$(nproc)` in Dockerfiles for parallel builds: `RUN make -j$(nproc)` — builds in containers respects the container's CPU quota, not the host's full count.

Related
lscpu uptime top
Open the full explainer →More in System & Processes

Reference text is hand-written and may be incomplete — check man nproc for your version. Test destructive commands on a non-production system first.