CentOS Debian Mint openSUSE Red Hat Ubuntu

Nice and Renice – Set Process Priority in Linux

Nice and Renice - Set Process Priority in Linux

Process priority is the one that directly impacts the priority of the schedule of the processes. All data related to processes and process priority are stored on the kernel. Such priorities can be defined manually and are assigned with a range value.

The kernel loads and executes the process that has a higher number of priorities first rather than the process with a low number of priorities. Such priorities can be set through nice and renice commands in Linux.

Nice Command

Nice is used to set the priority value so the process can be executed accordingly. The value for nice is set to -20 as the higher number of priority values and 19 as the lowest number of priority values. So processes with higher priority can be executed first.

Let’s check the priority status with the nice value of htop. You can run the command as follows.

$ ps -el | grep htop

You can see the nice value for htop is 0 for now. You can also check those stats with the “top” or “htop” command on Linux. To change the nice value, you can change the nice value as per below command.

$ nice -19 htop

Now check the nice value of htop with the following command.

$ ps -el | grep htop

Also, running the command htop will show the result as shown on the screenshot below.

But, when you want to set higher priority then you have to run commands with sudo privilege user. Here, when we tried to set a nice value for higher priority, permission denied is shown. But using sudo executes the command successfully. See the screenshot below for further details.

$ sudo nice --5 htop

Check by running the htop command which shows the result as shown on the screenshot below.

Renice Command

A nice command is used to set priority higher or lower for any process. But renice is used to set the priority higher or lower for the running process. It can set priority without stopping the process.

Using the ps command, you get the pid of the required process. Using grep for the specific process. In our case, we are executing the ps command for the pid of the htop process. See the screenshot below for further details.

$ ps -el | grep htop

With the above command, you have noticed pid, a nice value for the htop process. Now with these details, we can use renice command to change the priority of the running process as per the below command.

$ renice -n 10 -p 2257

Here, the running process with the same PID has new priority 10 set by the renice command for the process htop. So, you can easily change the priority with the renice command with the pid of the running process.


If you need to set such priority for the specific process for the kernel to load and execute the process with the correct management of CPU resources, these nice and renice come in handy. Thank you!

Similar Posts