Linux is famous for its ability to operate multiple processes at the same time. Many times it so happens that a heavy process utilizes a lot of resources, causing the functioning of the entire system to slow down. This is where the nice and renice command in Linux step in. They help you set the priority of processes, ensuring better performance.
Nice lets you set the priority of a process at the time of its start, while renice is used to change the priority of a running process. These are mostly used by system administrators and developers to tweak CPU scheduling for server reliability and avoid resource starvation.
This guide will cover everything: the difference between nice and the renice command in Linux, how to use the commands right, and practical examples with their outputs. By the end of this tutorial, you will be able to tell which command, between nice and renice, to use in a given situation.
What is a nice Command in Linux?
The nice command in Linux is used to start a new process at a given priority. This priority value is known as a niceness value, which may range between -20 (highest priority) and 19 (lowest priority).
Example:
nice -n 10 firefox
This runs Firefox with a niceness of 10
, giving it lower priority compared to default processes.
Get exclusive access to all things tech-savvy, and be the first to receive
the latest updates directly in your inbox.
What is the renice Command in Linux?
The renice
command changes the priority of an already running process. Instead of starting a process with priority, you can adjust it later by specifying its process ID (PID).
Example:
renice -n -5 -p 2345
This changes the priority of the process with PID 2345
to -5
, giving it higher CPU priority.
Difference Between nice and renice Command in Linux
The main difference between nice and renice command in Linux is that nice
sets the priority when starting a process, while renice
changes the priority of an existing process.
Feature | nice | renice |
---|---|---|
Purpose | Start a new process with priority | Modify priority of running process |
Input | Command + niceness value | PID + new niceness value |
Example | nice -n 10 firefox | renice -n -5 -p 2345 |
Comparison between nice and renice commands in Linux
When you compare nice and renice command in Linux, the difference lies in their timing and control:
- nice is proactive: you set the priority before the process begins.
- renice is reactive: you adjust the priority while the process is running.
Together, they give you complete control over CPU scheduling and resource allocation.
How to Use nice and renice Command in Linux?
Here are a few examples to use nice and renice command in Linux:
Using nice:
nice -n 15 python3 script.py
Output: The script runs with niceness 15
, consuming fewer CPU resources compared to default processes.
Using renice:
renice -n 5 -p 6789
Advanced usage of nice and renice
Now, we are going to discuss some advanced usages of nice and renice command in Linux:
Check process niceness:

ps -eo pid,comm,ni
This displays PID, command, and niceness of all processes
Give higher priority to a process:
sudo renice -n -10 -p 4321
Role of CyberPanel

CyberPanel is an open-source and free web hosting control panel. When you run CyberPanel, multiple services like OpneLiteSpeed, MariaDB, and PHP consume CPU at the same time. By using nice and renice command in Linux, you can:
- Lower priority for background tasks like log rotation.
- Raise priority for database processes under heavy traffic.
This ensures stable server performance and prevents downtime.
People Also Ask
What is the default niceness value in Linux?
The default niceness value is 0
. Processes without specified niceness start at this level.
Can a regular user set negative niceness values?
No, only the root (superuser) can assign negative niceness values for higher priority.
Is renice command permanent?
No, niceness changes made with renice
last only until the process ends or the system restarts.
How do I find the PID of a process to use with renice?
Use the ps aux
or top
command to find the PID of the process you want to adjust.
Conclusion
To sum up, the nice and renice command in Linux give you full control over how processes share CPU resources. You can manage both new and running tasks effectively by understanding the difference between the nice and renice command in Linux.
Try using nice
for your next process and adjust it with renice
to see the difference in action!