Print the number of available processing units.
low risk
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.
| Flag | Meaning |
|---|---|
--all | Print total number of processors, not just available |
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 →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.
Reference text is hand-written and may be incomplete — check man nproc for your version. Test destructive commands on a non-production system first.