Nice and Renice Command in Linux with Examples

nice command in Linux helps in execution of a program/process with modified scheduling priority. It launches a process with a user-defined scheduling priority. In this, if we give a process a higher priority, then Kernel will allocate more CPU time to that process. Whereas the renice command allows you to change and modify the scheduling priority of an already running process. Linux Kernel schedules the process and allocates CPU time accordingly for each of them.

Working with nice and renice Command

1. To check the nice value of a process.

ps -el | grep terminal

to-get-the-nice-value

The eight highlighted value is the nice value of the process.

2. To set the priority of a process



nice -10 gnome-terminal

priority-with-nice

This will set the nice value of the mentioned process.

3. To set the negative priority for a process

nice --10 gnome-terminal

negative-priority-with-nice

This will set the negative priorirty for the process.

4.changing priority of the runing process.

sudo renice -n 15 -p 77982

priority-of-running-porcess

This will change the priority of the process with pid 77982.

5. To change the priority of all programs of a specific group.

renice -n 10 -g 4

change-priority-of-group

This command will set all the processes of gid 4 priority to 10.

6. To change the priority of all programs of a specific user.

sudo renice -n 10 -u 2

to-change-priority-of-all-process-of-specific-user

This will set all the processes of user 2 to 10.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.