Open In App

Nice and Renice Command in Linux with Examples

Last Updated : 29 Aug, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

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 priority for the process. 

4.changing priority of the running 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.
 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads