Priority of process in Linux | nice value
Last Updated :
14 Oct, 2024
In Linux, every running program is considered a process. Each process requires space in RAM and CPU time to execute. Processes have assigned priorities, which dictate the order in which they are executed by the CPU. This priority is managed using the nice value, a parameter that determines how much CPU time a process gets. we will discuss how the nice and renice commands are used to manage process priorities. The running instance of the program is process, and each process needs space in RAM and CPU time to be executed, each process has its priority in which it is executed. Now observe the below image and see the column.
nice and renice Commands
The nice command is used to start a process with a specified nice value, while the renice command is used to alter priority of the running process.
Nice Command Syntax
nice [OPTION] [COMMAND [ARG]...]
where,
- OPTION: Set the nice value (e.g., -n).
- COMMAND: Command to be executed with the specified priority.
- ARG: Arguments passed to the command.
Renice Command Syntax
renice [PRIORITY] [-p PID]
where,
- PRIORITY: The new priority to be assigned to a process.
- -p PID: The Process ID (PID) of the process you want to modify.

top command output
The column NI represents nice value of a process. It’s value ranges from -20 to 20(on most unix like operating systems).
-20:- most priority Process
20: - least priority Process
One important thing to note is nice value only controls CPU time assigned to process and not utilization of memory and I/O devices.
Common Options Used with the Commands
|
Option
|
Description
|
|
-n
|
Set the nice value for a new process.
|
|
-p
|
Modify the nice value for a process using its PID.
|
Usage of nice command
Now let’s assume the case that system has only 1GB of RAM and it’s working really slow, i.e. programs running on it(processes) are not responding quickly, in that case if you want to kill some of the processes, you need to start a terminal, if you start your bash shell normally, it will also produce lag but you can avoid this by starting the bash shell with high priority.
For example:
nice -n -5 bash
First observe output of top without setting nice value of any process in below image:

nice value of top is 0
Now start a bash shell with nice value -5, if you see the highlighted line, the top command which is running on bash shell has nice value set to -5

nice value of bash shell is -5
Usage of renice command
To alter priority of running process, we use renice command.
renice value PID
value is new priority to be assigned PID is PID of process whose priority is to be changed One thing to note is you can’t set high priority to any process without having root permissions though any normal user can set high priority to low priority of a process. We will see one example of how you alter priority of process.

nice value of gnome terminal is 0
You can observe that nice value of process(PID = 2371) is 0, now let’s try to set the new priority of 5 to this process.
renice 5 2371
Output:
2371 (process ID) old priority 0, new priority 5
You can also see this priority using top command(see highlighted line in image).

process 2371 has nice value 5
Conclusion
The nice and renice commands are useful tools for managing process priorities in Linux. By adjusting the nice values, you can control how much CPU time is allocated to processes, which helps in managing system performance. However, keep in mind that normal users can only decrease a process’s priority, while increasing the priority (i.e., setting a negative nice value) requires root privileges.
nice value – FAQs
What is the nice value in Linux?
The nice value in Linux is a parameter that controls the priority of a process. A lower nice value means higher priority and vice versa. It ranges from -20 (highest priority) to 19 (lowest priority).
How do you check the nice value of a process?
You can check the nice value of a process using the top command or by running ps -o ni -p <PID>.
Can a normal user increase the priority of a process?
No, increasing the priority (i.e., setting a negative nice value) requires root privileges. Normal users can only lower the priority of their processes.
What is the difference between nice and renice?
The nice command is used to start a new process with a specified nice value, while the renice command is used to change the nice value of an already running process.
Similar Reads
How to sort lines in text files in Linux | sort Command
SORT command is used to sort a file, arranging the records in a particular order. By default, the sort command sorts file assuming the contents are ASCII. Using options in the sort command can also be used to sort numerically. SORT command sorts the contents of a text file, line by line.sort is a s
7 min read
Ulimit, Soft Limits and Hard Limits in Linux
ulimit is admin access required Linux shell command which is used to see, set, or limit the resource usage of the current user. It is used to return the number of open file descriptors for each process. It is also used to set restrictions on the resources used by a process. Syntax: To check the ulim
2 min read
Subzy - Subdomain takeover Vulnerability Checker Tool
Subzy is the tool that identifies or checks the subdomain takeover on the target domain or multiple subdomains. Subzy is the Golang language based-tool. Subdomain takeover tool, which works based on matching response fingerprints from can-i-take-over-xyz. This automated scanner can help you in bug b
4 min read
Hash-Buster v3.0 - Crack Hashes In Seconds
Hashing is a cryptographic method that can be used to authenticate the authenticity and integrity of various types of information. It is widely used in authentication systems to circumvent storing plaintext passwords in databases but is also used to authenticate files, documents, and other types of
2 min read
Essential Unix Commands
Unix commands are a set of commands that are used to interact with the Unix operating system. Unix is a powerful, multi-user, multi-tasking operating system that was developed in the 1960s by Bell Labs. Unix commands are entered at the command prompt in a terminal window, and they allow users to per
7 min read
Ansible
Ansible is an open-source IT engine that automates application deployment, cloud provisioning, intra-service orchestration, and other IT tools. It is an automation and orchestration tool popular for the following reasons: Simple to Install.Free and open source.Lightweight and consistent.OpenSSH secu
6 min read
Technological Evolution in Finance Management
Today, technology is changing the way businesses operate and deliver products to consumers in many fields. We have medical equipment that can identify life-threatening conditions in our body, alarms that detect poisonous substances in the air, and smarter computer software that makes controlling vit
7 min read
How to Install an APK on the Emulator in Android Studio?
In this article, we will know, how we can install APK in our Android Studio Emulator. There are several methods to do that but most of them are quite unreliable and confusing but in this article, we are going to do that with some very easy methods with some very easy steps. Method 1 Step 1: Opening
2 min read
How to Clear Browser Cache On Windows 10
You must clear your browser cache periodically to ensure that your web browser is not taking excess loading time. However, clearing the browser cache will have a different approach across browsers. Follow these steps to clear your browsing cache in Windows 10 across Google Chrome, Microsoft Edge, an
4 min read
R vs Python in Datascience
Data science deals with identifying, representing and extracting meaningful information from data sources to be used to perform some business logics.The data scientist uses machine learning, statistics, probability, linear and logistic regression and more in order to make out some meaningful data. F
7 min read
HTML DOM closest() Method
The closest() method of the element interface is used to traverse the element and its parents in the HTML Document Tree until it finds the first node that matches the selector string that is provided. Syntax: targetElement.closest( selectors ) Parameters: This method accepts a single parameter as me
2 min read
Python | Get values of particular key in list of dictionaries
Sometimes, we may require a way in which we have to get all the values of the specific key from a list of dictionaries. This kind of problem has a lot of applications in the web development domain in which we sometimes have a JSON and require just to get a single column from records. Let's discuss c
10 min read
PHP | XMLReader next() Function
The XMLReader::next() function is an inbuilt function in PHP which is used to move cursor to next node skipping all subtrees. Another usage of this function is it accepts the name of the node to directly move to the element.Syntax: bool XMLReader::next( string $localname ) Parameters: This function
2 min read
Longest Common Prefix
Given an array of strings arr[], the task is to return the longest common prefix among each and every strings present in the array. If there’s no prefix common in all the strings, return “”. Examples: Input: arr[] = [“geeksforgeeks”, “geeks”, “geek”, “geezer”]Output: “gee”Explanation: “gee” is the l
5 min read
How to increase & decrease Image Brightness in CSS ?
In this article, we will learn about how to increase and decrease image brightness in CSS. CSS (Cascading Style Sheets) is a stylesheet language used to design a webpage to make it attractive. The reason for using this is to simplify the process of making web pages presentable. It allows you to appl
2 min read
BigDecimal byteValueExact() Method in Java
The java.math.BigDecimal.byteValueExact() is an in-built function which converts the BigDecimal to a byte and checks for lost information. Any BigDecimal value greater than 127 or less than -128, will generate an exception as it doesn't fit in byte range. Syntax: public byte byteValueExact() Paramet
2 min read
How to add stroke width of text canvas using Fabric.js ?
In this article, we are going to see how to add stroke width to the text canvas using FabricJS. The canvas means text written is movable, rotatable, resizable, and can be stretched. But in this article, we will add a stroke width. Further, the text itself cannot be edited like a textbox.Approach: To
2 min read
PyQt5 ComboBox – Different border size when editable and in on state
In this article we will see how we can set different border width to the combo box when it is editable and is in on state, when we set border to the combo box it is of same color for all the sides although we can change color of each sides respectively. Different border width will only appear combo
2 min read
Generate all numbers up to N in Lexicographical Order
Given an integer N, the task is to print all numbers up to N in Lexicographical order. Examples: Input: N = 15 Output: 1 10 11 12 13 14 15 2 3 4 5 6 7 8 9 Input: N = 19 Output: 1 10 11 12 13 14 15 16 17 18 19 2 3 4 5 6 7 8 9 Approach: In order to solve the problem, follow the steps below: Iterate fr
9 min read