How to Change Nice Value in htop?
This article provides a quick, step-by-step guide on how to directly
alter the nice value—and consequently the scheduling priority—of a
running process using the htop interactive text-mode
process viewer in Linux. You will learn the specific keyboard shortcuts
required to increase or decrease a process’s niceness, as well as the
administrative permissions needed to lower a nice value for better CPU
allocation.
Step 1: Launch htop
Open your terminal and start the utility by typing htop.
If it is not installed, you can typically install it via your package
manager (e.g., sudo apt install htop on Debian/Ubuntu or
sudo dnf install htop on Fedora/RHEL).
Step 2: Navigate to the Target Process
Use the Up and Down arrow keys on your keyboard to scroll through the running processes and highlight the specific process you wish to modify. You can also press F3 or / to search for a process by its name.
Step 3: Adjust the Nice Value
Once the process is highlighted, use the following keyboard shortcuts to change its niceness:
- Press F7 (or ‘]’ key): Decreases the nice value. A lower nice value increases the process priority, giving it more CPU time.
- Press F8 (or ‘[’ key): Increases the nice value. A higher nice value makes the process “nicer” to other tasks, lowering its CPU priority.
Understanding Permission Constraints
Any standard user can increase the nice value of their own processes
to surrender CPU cycles. However, only the root user (or a user with
sudo privileges) can decrease a nice value below
0 or lower the nice value of an existing process. If you
need to grant a process maximum CPU priority, you must launch the
utility with administrative privileges by running
sudo htop.