One of the parameters used by the kernel to assign process priority is supplied by the user and is called a nice number. The nice command[1] is used to assign a priority number to the process. It is so named because it normally causes programs to execute with lower priority levels than their default. Thus, the process is being “nice” to other processes on the system by yielding CPU time. With this scheme, more “niceness” implies a lower priority, and less niceness implies a higher priority.

By default, user processes are created with a nice number of zero. Positive numbers lower the priority relative to other processes, and negative numbers raise it. For example, if you have a long-running utility and don’t want to impact interactive performance, a positive nice number will lower the job’s priority and improve interactive performance.

Nice numbers range from –20 to +19. Any user can start a process with a positive nice number, but only the superuser (root) can lower a process’s nice number and thus raise its priority. Remember, the lower the nice number, the higher the priority to the CPU.

[1] Some shells, not including bash, have a built-in nice command.

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.