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
The eight highlighted value is the nice value of the process.
2. To set the priority of a process
nice -10 gnome-terminal
This will set the nice value of the mentioned process.
3. To set the negative priority for a process
nice --10 gnome-terminal
This will set the negative priorirty for the process.
4.changing priority of the runing process.
sudo renice -n 15 -p 77982
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
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
This will set all the processes of user 2 to 10.