nice and renice Commands in Linux: Process Priority Syntax & Examples

nice starts a command with a lower or higher CPU scheduling priority (nice value -20 to 19). renice changes the nice value of processes that are already running — by PID, process group, or user.

Published

Updated

Read time 9 min read

Reviewed byDeepak Prasad

nice and renice Commands in Linux: Process Priority Syntax & Examples
About nice starts a command with a lower or higher CPU scheduling priority (nice value -20 to 19). renice changes the nice value of processes that are already running — by PID, process group, or user.
Tested on Ubuntu 25.04 (Plucky Puffin); nice 0.2.2 (uutils); renice 2.40.2; kernel 7.0.0-27-generic
Package uutils-coreutils / util-linux (apt/deb) · coreutils / util-linux (dnf/rpm)
Man page nice / renice(1)
Privilege renice usually needs root / sudo for lowering nice (raising priority)
Distros

All major Linux distros ship nice and renice.

Real-time scheduling policies: use chrt instead of nice (see man chrt).

nice and renice — quick reference

nice — start a command with a set priority

Launch a program with a nice value before it starts. With no command, nice prints your shell's current nice value (usually 0).

When to use Command
Show your current nice value nice
Start a command with default extra niceness (+10) nice command
Add a specific increment to niceness (higher number = lower CPU priority) nice -n 10 command
Same with long option nice --adjustment 10 command
Give a background job more CPU share (needs permission to use negative nice) sudo nice -n -5 command
Show brief usage nice --help
Show package version nice --version

renice — change priority of running processes

Adjust nice values for processes that are already running. Lowering nice (negative numbers) usually needs root.

When to use Command
Lower priority of a running process by PID sudo renice -n 10 -p PID
Set an absolute nice value (ignores POSIX relative mode) sudo renice --priority 5 -p PID
Add a relative increment when POSIX mode is on renice --relative 5 -p PID
Change all processes owned by a user sudo renice -n 5 -u username
Change every process in a process group sudo renice -n 5 -g PGID
Show brief usage renice --help
Show package version renice --version

nice and renice — command syntax

Synopsis from nice --help and renice --help on Ubuntu 25.04:

text
nice [OPTION] [COMMAND [ARG]...]

renice [-n|--priority|--relative] <priority> [-p|--pid] <pid>...
renice [-n|--priority|--relative] <priority>  -g|--pgrp <pgid>...
renice [-n|--priority|--relative] <priority>  -u|--user <user>...

Nice values range from -20 (most favorable to the process) to 19 (least favorable). Only root can assign negative nice values to ordinary users' workloads. These tools apply to the SCHED_OTHER time-sharing policy — not real-time FIFO/RR scheduling.


nice and renice — command examples

Essential Check your current nice value

Before changing priority, see what nice value your shell already has. A normal login shell usually shows 0.

Run the command:

bash
nice

Sample output:

text
0

The number is the nice value the kernel will use for child processes you start from this shell unless you pass -n to nice.

One-line takeaway: nice with no arguments is a quick sanity check — not a process list.

Essential Start a background job with lower CPU priority

When a long batch job should not compete with interactive work, start it with a higher nice number. 15 is a common choice for "run when spare CPU is available."

Run the command:

bash
nice -n 15 sleep 30 &
NPID=$!
sleep 0.3
ps -o pid,ni,cmd -p $NPID

Sample output:

text
PID  NI CMD
  53154  15 sleep 30

The NI column is the nice value. Higher NI means the scheduler favors other processes when the CPU is busy.

Clean up the test job:

bash
kill $NPID

One-line takeaway: nice -n N command sets priority at launch — use it for backup scripts, compiles, or downloads you want to stay in the background.

Common Lower priority of a running process by PID

nice only works at start time. When a process is already eating CPU, use renice with its PID.

Start a test process and note its PID:

bash
sleep 300 &
RPID=$!
ps -o pid,ni,cmd -p $RPID

Sample output:

text
PID  NI CMD
  52550   0 sleep 300

Raise the nice value (lower CPU priority):

bash
sudo renice -n 10 -p $RPID
ps -o pid,ni,cmd -p $RPID

Sample output:

text
52550 (process ID) old priority 0, new priority 10
    PID  NI CMD
  52550  10 sleep 300

Clean up:

bash
kill $RPID

One-line takeaway: renice -n 10 -p PID is the standard way to push an already-running hog into the background without killing it.

Common Set an absolute nice value with --priority

On Ubuntu 25.04, renice -n can behave as a relative adjustment when POSIXLY_CORRECT is set. Use --priority when you want a fixed nice value regardless of environment.

Run the command:

bash
sleep 300 &
RPID=$!
sudo renice --priority 5 -p $RPID
ps -o pid,ni,cmd -p $RPID

Sample output:

text
52556 (process ID) old priority 0, new priority 5
    PID  NI CMD
  52556   5 sleep 300

Clean up:

bash
kill $RPID

One-line takeaway: prefer --priority in scripts when you need a predictable absolute nice value.

Advanced Renice every process owned by a user

When one account is running many CPU-heavy jobs, renice by user instead of chasing individual PIDs.

Run the command:

bash
sleep 60 &
RPID=$!
sudo renice -n 3 -u root

Sample output:

text
0 (user ID) old priority -20, new priority 3

The line reports how many processes were updated. Verify one process:

bash
ps -o pid,ni,user,cmd -p $RPID

Clean up:

bash
kill $RPID

One-line takeaway: renice -u is useful on shared servers when a single user's workload needs throttling — but only root can lower nice for other users' processes.

Advanced Give a job more CPU share (root only)

Negative nice values (-1 through -20) favor the process. Regular users cannot assign negative nice to their own jobs on most systems — root can.

Run the command:

bash
sudo nice -n -5 sleep 0.2
echo exit:$?

Sample output:

text
exit:0

If permission is denied without sudo, you will see an error instead of a clean exit. Check the result with ps -o ni,cmd while the short sleep runs.

One-line takeaway: reserve negative nice for truly latency-sensitive daemons — misusing it can starve other services on the same host.


nice and renice — when to use / when not

Use nice / renice when Use something else when
You want to nudge SCHED_OTHER batch or background work so interactive shells stay responsive You need hard real-time guarantees — use chrt and appropriate kernel config
The process is already running and you only need a softer CPU share The process should be stopped or killed — use kill, pkill, or cgroup limits
You are tuning ordinary user workloads on a shared server You need I/O or memory limits — use cgroups/systemd slices or ionice for disk priority
You can accept that priority is a hint, not a reservation You need per-user resource caps enforced by the OS — use systemd, cgroups v2, or container limits

nice and renice vs chrt

nice / renice chrt
Scheduling policy SCHED_OTHER only SCHED_OTHER, SCHED_FIFO, SCHED_RR
Scope Nice level -20 … 19 Policy + static priority for RT classes
Typical use Background compiles, backups, throttling runaway CPU Low-latency audio, industrial control, RT threads
Who can lower priority (raise nice) Any user for own processes Root for RT policies

nice and renice are the everyday tools for time-sharing workloads. chrt changes scheduling policy, not just nice level within SCHED_OTHER.


Commands you often use in the same workflow — inspect processes, then adjust or stop them.

Command One line
nice / renice Set or change CPU nice value (this page)
top Live view of CPU use and NI column
ps Snapshot process list with -o ni
kill Send signals to stop or restart a process

Browse the full index in our Linux commands reference.


nice and renice — interview corner

What does the nice value mean in Linux?

The nice value is a number from -20 to 19 that tells the CPU scheduler how aggressively to run a process under the normal SCHED_OTHER policy. Lower nice (including negative numbers) means more CPU time when cores are busy. Higher nice means the process willingly steps aside for others.

It is called "nice" because a positive value is you being nice to other users on the machine. It is not an absolute guarantee — the kernel still preempts processes for fairness and interrupts.

Check a running process:

bash
ps -o pid,ni,cmd -p PID

A strong answer is:

"Nice is a SCHED_OTHER scheduling hint from -20 (highest CPU favor) to 19 (lowest). Positive nice throttles background work; negative nice needs root and favors latency-sensitive jobs."

What is the difference between nice and renice?

nice sets priority when you start a command:

bash
nice -n 10 ./long_job.sh

renice changes priority after the process is already running:

bash
sudo renice -n 10 -p PID

You cannot use nice on an existing PID. You cannot use renice before the process exists. Together they cover "launch gently" and "throttle what is already running."

A strong answer is:

"nice applies at exec time; renice adjusts live processes by PID, process group, or user. I use nice for new batch jobs and renice when something already running needs throttling."

Who can set a negative nice value?

On typical Linux systems, only root (or a process with CAP_SYS_NICE) can assign negative nice values. Ordinary users can raise their own nice (lower priority) freely but cannot make their jobs more aggressive than the default without privilege.

That prevents every user from claiming high CPU share. Admins use sudo nice -n -5 … or sudo renice sparingly for trusted daemons.

A strong answer is:

"Negative nice requires root or CAP_SYS_NICE. Regular users can only increase nice to deprioritize their own work, not grab more CPU."

How do renice -p, -g, and -u differ?

All three take a priority and a target, but the target type changes:

Flag Target
-p / --pid One or more process IDs (default)
-g / --pgrp Process group ID — every member of the group
-u / --user User name or UID — all matching processes

Example:

bash
sudo renice -n 5 -u www-data

Use -p for a single runaway job, -u when an entire account needs throttling, -g when you spawned a pipeline or job group together.

A strong answer is:

"renice -p targets PIDs, -g targets a process group, -u targets all processes for a user. I pick the narrowest scope that fixes the problem."


Troubleshooting

Symptom Likely cause Fix
Permission denied when using negative nice Non-root user Run with sudo or accept a positive nice only
renice: …: No such process PID exited or typo Confirm with ps -p PID
Nice change has little visible effect Host is idle or cgroup CPU limit applies Check systemd-cgtop, cgroup limits, or container caps
renice -n behaves unexpectedly POSIXLY_CORRECT set in environment Use --priority for absolute values
Process still dominates CPU Single-threaded hog on many-core box, or I/O bound Combine with cgroup CPUQuota, cpulimit, or fix the app

References

Rohan Timalsina

is a technical writer and Linux enthusiast who writes practical guides on Linux commands and system administration. He focuses on simplifying complex topics through clear explanations.