Robert Elder Software Inc.
  • Home
  • Store
  • Blog
  • Contact
  • Home
  • Store
  • Blog
  • Contact
  • #linux
  • |
  • #commandline
  • |
  • #softwareengineering
  • |
  • #embeddedsystems
  • |
  • #compilers
  • ...
  • View All >>

Intro To 'nproc' Command In Linux

2023-07-15 - By Robert Elder

     I use the 'nproc' command to show many processors my machine has:

nproc

A Typical Use Case

     On my machine, the 'nproc' command prints the value 8:

8

     I can check the contents of '/proc/cpuinfo' to obtain my CPU's model number and compare the value of 8 against the official documentation for my processor:

cat /proc/cpuinfo | grep 'model name'

     As you can see from above, my CPU is an 'i5-10300H', and the documentation shows that 8 is indeed the number of logical CPU cores that my computer has.  However, the number of physical cores in my CPU is 4.

Options & Environment Variables

     The value returned by the 'nproc' command can also be influenced by the following two environment variables:

OMP_NUM_THREADS=999 nproc
999
OMP_THREAD_LIMIT=7 nproc
7

     It can also be influenced by 'all' flag:

OMP_THREAD_LIMIT=7 nproc --all
8

     and the 'ignore' flag:

OMP_THREAD_LIMIT=7 nproc --all --ignore=5
3

     Unlike many other commands, the 'nproc' command is not included in the POSIX standard.  In the GNU coreutils implementation of the 'nproc' command, you can see that there are many different system calls for every different platform that the 'nproc' command can run on. Different software platforms or BIOS settings could affect the value returned by the 'nproc' command. Furthermore, concepts like hyperthreading, or power efficiency features could further complicate the process of accurately counting CPU cores.

     And that's why the 'nproc' command is my favourite Linux command.

Intro To 'stty' Command In Linux
Intro To 'stty' Command In Linux
Published 2023-10-04
Terminal Block Mining Simulation Game
$1.00 CAD
Terminal Block Mining Simulation Game
Intro To 'comm' Command In Linux
Intro To 'comm' Command In Linux
Published 2023-09-06
How To Force The 'true' Command To Return 'false'
How To Force The 'true' Command To Return 'false'
Published 2023-07-09
A Surprisingly Common Mistake Involving Wildcards & The Find Command
A Surprisingly Common Mistake Involving Wildcards & The Find Command
Published 2020-01-21
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01
Intro To 'chroot' Command In Linux
Intro To 'chroot' Command In Linux
Published 2023-06-23
Intro To 'sha256sum' Command In Linux
Intro To 'sha256sum' Command In Linux
Published 2023-08-30
Join My Mailing List
Privacy Policy
Why Bother Subscribing?
  • Free Software/Engineering Content. I publish all of my educational content publicly for free so everybody can make use of it.  Why bother signing up for a paid 'course', when you can just sign up for this email list?
  • Read about cool new products that I'm building. How do I make money? Glad you asked!  You'll get some emails with examples of things that I sell.  You might even get some business ideas of your own :)
  • People actually like this email list. I know that sounds crazy, because who actually subscribes to email lists these days, right?  Well, some do, and if you end up not liking it, I give you permission to unsubscribe and mark it as spam.
© 2025 Robert Elder Software Inc.
SocialSocialSocialSocialSocialSocialSocial
Privacy Policy      Store Policies      Terms of Use