Linux Command: nproc
Print the number of processing units available
nproc prints the number of available processing units (CPU cores/threads). It is the simplest way to determine how many parallel tasks the system can handle. nproc is commonly used with make -j for parallel compilation and with xargs -P for parallel command execution. It respects cgroup limits in containers, making it more accurate than parsing /proc/cpuinfo. nproc outputs a single number, making it perfect for command substitution in scripts.
Syntax
nproc [OPTION]...Common Examples
nproc— Shows the number of available processing units.make -j$(nproc)— Compiles using all available CPU cores.find . -name '*.png' | xargs -P $(nproc) -I {} convert {} -resize 50% {}— Processes images in parallel using all cores.make -j$(($(nproc) - 1))— Compiles using all cores except one, keeping system responsive.
Pro Tips
Master this and 230+ other Linux commands with our comprehensive eBooks and cheat sheets.
Related Resources