Open In App

nproc Command in Linux with Examples

Last Updated : 06 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

nproc It is a simple Unix command which is used to print the number of processing units available in the system or to the current process. This command could be used in system diagnostics and related purposes. It is part of GNU Core utils, so it comes pre-installed with all modern Linux operating systems.

Syntax

nproc [Arguments] ...

Working with nproc Command

Here are some practical examples of how to use the nproc command effectively:

1. Use nproc command

Simply running the nproc command without any arguments will display the number of processing units available to the current process

nproc

Use nproc command

It prints the number of processing units available to the current process. It may be less than the number of online processors.

2. Print total installed processing units

We use the “–all” option when we want nproc to display the total installed processing units.

nproc --all

Print total installed processing units

3. To exclude some processing units

We use “–ignore” option when we want nproc to exclude a set number of processing units.

nproc --ignore=4

To exclude some processing units

4. Get the help section

This command will display the help section of the nproc command which will have all the information related to the nproc command.

nproc --help

Get the help section

5. Get the Display version

This command will display the version of nproc command in Linux.

nproc --version

Get the Display version

6. Get the nproc manual

This command will print the manual of the nproc command.

man nproc

Get the nproc manual

Conclusion

The nproc command remains as one of the useful tools for the Linux system administrator reviewing that will help them in monitoring the number of CPU resources in a system without a lot of complications. As such, the overall performance of the system can be improved since users are able to differentiate quickly the number of these processing units available easily.

nproc is used in shell scripts to configure systems automatically, together with other commands such as make for parallel compilation, or when used on its own for system analysis purposes, it will give accurate information about the availability of the CPU. –all and –ignore options make it comfortable to set how the processing units should be calculated and described based on the needs of a particular task.



Next Article

Similar Reads