Linux nice Command: Set a New Process's Scheduling Priority

nice specifies the nice value used for CPU scheduling when starting a new command. A nice value higher than the default generally indicates a tendency to yield the CPU to other tasks more easily.

What is the nice command?

The typical range of nice values in Linux is from -20 to 19, with lower values indicating higher priority. nice does not change processes that are already running. Use renice for running tasks.

Basic syntax

nice -n adjustment_value command [arguments...]

The installed implementation and options may vary depending on the distribution. Check your system's documentation with man nice.

Examples

Start with low priority

Start a read operation with a nice value 10 higher than the default.

nice -n 10 sha256sum large.log

Start with the default increment

In the GNU implementation, if the adjustment value is omitted, the default increment is used.

nice sha256sum large.log

Check the actual value

Check the NI column of the running process.

ps -p 1234 -o pid,ni,cmd

Checking the nice value of a new process

nice sets the scheduling nice value of a newly started process. The following is an example of starting a test sleep with a value of 10 and then checking it.

nice -n 10 sleep 60 &
ps -o ni,comm -p $!

Example output:

 NI COMMAND
 10 sleep

$! is the PID of the most recent background process. Generally, the higher the number, the lower the CPU scheduling priority, but this does not mean a limit on CPU usage. To change the value of a process that is already running, use renice.

Main Options and Format

Options/Format Description
-n value Specifies the adjustment value for the new command based on the existing nice value.
--adjustment=value Long option format in the GNU implementation.
run without arguments Displays the current nice value in the GNU implementation.

Precautions when using

The nice value is a hint for CPU scheduling; it does not guarantee execution time or change memory or disk I/O priorities. Raising priority by lowering the nice value may not be allowed for regular users. For major load issues, first check the cause process and the type of resource.

Frequently Asked Questions

Does nice -n 10 make it 10 times faster?

No. A higher value generally means a lower CPU priority, and it does not indicate a fixed multiple of processing speed.

Official Documentation

The exact behavior of the option and implementation differences can be found in the official documentation for nice.

More in This Category
Linux fsck Command: Check and Repair Filesystems

Linux fsck Command: Check and Repair Filesystems

Learn how to check and Repair Filesystems with the Linux fsck command, including practical examples, key options, and important precautions.

Linux Tutorial / Understand Users, Groups, and File Ownership

Linux Tutorial / Understand Users, Groups, and File Ownership

Understand UIDs, GIDs, primary and supplementary groups, and file ownership, then inspect them safely with id, groups, getent, ls, and stat.

Linux clear Command: Clear the Terminal Display

Linux clear Command: Clear the Terminal Display

Learn how to use the Linux clear command to clear the visible terminal screen and understand scrollback behavior, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux printf Command: Print Values with a Defined Format

Linux printf Command: Print Values with a Defined Format

Learn how to print Values with a Defined Format with the Linux printf command, including practical examples, key options, and important precautions.

Linux Tutorial / File Permissions and Safe sudo Use

Linux Tutorial / File Permissions and Safe sudo Use

Learn to read file and directory permissions, practice chmod safely, and understand when to use sudo and how to diagnose access errors.

Linux awk Command: Analyze Text by Fields

Linux awk Command: Analyze Text by Fields

Learn how to analyze Text by Fields with the Linux awk command, including practical examples, key options, and important precautions.

Linux cd Command: Change the Current Directory

Linux cd Command: Change the Current Directory

Learn how to use the Linux cd command to move between directories using absolute, relative, home, and previous paths, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux rm Command: Remove Files and Directories Safely

Linux rm Command: Remove Files and Directories Safely

Learn how to remove files and directory trees with Linux rm, use interactive safeguards, limit recursive deletion, and avoid destructive path mistakes.

Linux less Command: Browse and Search Long Text Files

Linux less Command: Browse and Search Long Text Files

Learn how to browse long files with Linux less, move forward and backward, search text, follow growing logs, preserve colors, and exit the pager.

Linux date Command: Display and Format the Current Time

Linux date Command: Display and Format the Current Time

Learn how to display and Format the Current Time with the Linux date command, including practical examples, key options, and important precautions.