Commands.page Logo

How to Change Process Priority in htop on Ubuntu

Managing system resources effectively often requires adjusting how much CPU time specific applications receive. This article explains how to modify process priority values directly within the htop interface on Ubuntu. You will learn the specific keyboard shortcuts needed to increase or decrease priority and understand the permissions required to make these changes stick.

Install and Launch htop

If you have not installed htop yet, open your terminal and run sudo apt install htop. Once installed, launch the tool by typing htop in the terminal. For the best results, run it with sudo privileges using sudo htop, as changing priority often requires root access.

Select the Process

Use the arrow keys to navigate through the list of running processes. Highlight the specific process you wish to modify. You can also sort the list by CPU or Memory usage by pressing F6 to find resource-heavy tasks quickly.

Adjust the Priority

To change the priority, use the following function keys while a process is highlighted:

In Linux, priority is managed via the โ€œNiceโ€ value, which ranges from -20 to 19. A lower Nice value means a higher priority. Therefore, pressing F7 makes the process more important to the scheduler, while F8 makes it less important.

Permission Requirements

You can increase the priority of your own processes without special permissions. However, lowering the Nice value below 0 or changing the priority of processes owned by other users requires root privileges. If you did not launch htop with sudo, you will receive an error message when attempting to increase priority beyond the default limit.

Verify the Change

Observe the โ€œNIโ€ column in the htop interface. This column displays the current Nice value of each process. After pressing F7 or F8, the number in this column should update immediately to reflect the new priority setting.