Changing the default nice value for a user or group

How to make a niceness value default for any user or group using /etc/security/limits.conf

Written by Benjamin Cane on 2013-09-30 | 1 min read

Recently I coveredhow to increase and decrease the CPU priority of processes using nice and renice. Today I am going to cover how to change the default niceness value for a user or group.

Why change the default CPU priority value?

Before explaining how to change the default niceness value, let's cover why this could be useful.

Scenario #1

You have a system that has thousands of users that log in via SSH and could potentially run CPU intensive tasks. By making the niceness value higher you will ensure that critical system processes will get higher CPU priority than the jobs ran by the users.

Scenario #2

You have a production system that is sensitive to CPU spikes and want to ensure that one application has a higher priority than other applications or people users. By setting a lower niceness value for your important application you can advise the kernel to give that application users processes a higher priority.

While not every system needs this level of control; there are scenarios where it makes sense to give some processes higher priority than others.

Changing the default niceness value

To set the default niceness value for a specific user we will use the /etc/security/limits.conf file.

Setting the default priority on a user

# vi /etc/security/limits.conf


madflojo soft priority 5

All new logins from the user madflojo will now receive a niceness value of 5.

Setting the default priority on a group

# vi /etc/security/limits.conf


@users soft priority 5

From this point all new logins by the users in the users group will also receive a niceness value of 5.

$ nice
$ ssh localhost
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
[email protected]'s password:
$ nice

That's it, that is all of the editing required to change the default priority for users and groups. This value can be positive or negative and does not impact the ability of a user to adjust the niceness of processes to a "nicer" value.

Picture of Benjamin Cane

Benjamin's specialty is keeping the lights on for mission critical systems. He is currently building applications that enable high concurrency financial transactions.

Recently Benjamin published his first book; Red Hat Enterprise Linux Troubleshooting Guide. In addition to writing, he has several Open Source projects focused on making Ops easier. These projects include Automatron, a project enabling auto-healing infrastructure for the masses.


Identify, capture and resolve common issues faced by Red Hat Enterprise Linux administrators using best practices and advanced troubleshooting techniques

What people are saying:
Excellent, excellent resource for practical guidance on how to troubleshoot a wide variety of problems on Red Hat Linux. I particularly enjoyed how the author made sure to provide solid background and practical examples. I have a lot of experience on Red Hat but still came away with some great practical tools to add to my toolkit. - Amazon Review