Skip to content
Related Articles

Related Articles

Nice and Renice Command in Linux with Examples

View Discussion
Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 29 Aug, 2021
View Discussion
Improve Article
Save Article

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.
 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!