Course Objectives Covered
Executing Commands at the Command Line (3036)
Common Command Line Tasks (3036)
Multiuser Processes and Multitasking in the Linux System (3036)
When a process starts, it does so at a default priority of zero. This puts it on an even keel with all other processes competing for attention from the CPU and other resources. The priorities for the processes can be changed through the use of two utilities, nice and renice.
Processes can be started at different priorities using the nice utility. There are 40 different levels that nice can be used with (half negative and half positive), including
19 (lowest priority)
0 (default priority)
-20 (highest priority)
A user can use only the negative numbers, meaning that the user can only lower a process and not raise it. You can also specify an increment (default is 10), with the -n option, that nice will use to change the priority over time. The root user (superuser) has the ability to give a negative increment, whereas all other users cannot.
Negative values are confined to use only by the superuser.
If only the nice command is given, it will show the scheduling priority used by default.
The nice utility can only be used when starting a process, and cannot be used with a process already running. That is where the renice utility comes into play. The utility uses the same priorities available to nice and is followed by one of three options:
-p for PIDs
-g for a process group
-u for a group associated with a user