Sharing Knowledge | System Admin Articles

Setting Limits for Users in Linux

We can set useful limits for users which is useful to control the resource utilization in Linux. This can be configured in /etc/security/limits.conf. To activate these limits you need to add the following line to the bottom of /etc/pam.d/login file in your Linux server.

session required /lib/security/

Entries in limits.conf file have the following structure:
[username or @groupname]          [type resource]        [limit]
Group names must be preceded by the @ to distinguish them from usernames.
The type must be either soft or hard. Soft-limits can be exceeded and are usually warning marks whereas hard-limits cannot be exceeded. A resource type can be one of the following keywords:

 Limits the size of a core file (KB).
 Maximum data size (KB).
 Maximum file size (KB).
 Maximum locked in memory address space (KB).
 Maximum number of open files.
 Maximum resident set size (KB).
 Maximum stack size (KB).
 Maximum CPU time in minutes.
 Maximum number of processes.
 Address space limit.
 Maximum number of logins allowed for this user.

Below is example of limits.conf file. In this example, oracle user set to memlock limit of 12582912 and all the users in the server set with nproc and nofile limits.

# Added for Oracle Database Server
* soft nproc 2047
* hard nproc 16384
* soft nofile 1024
* hard nofile 65536

oracle soft memlock 12582912
oracle hard memlock 12582912

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4
# End of file

Labels: Linux

My Profile PhotoAbout the Author

I'm Parthiban, An UNIX System Admin by Profession. I'm Experienced in Linux/Unix System Administration and Scripting. I have done lot of work on the infrastructure Mgmt side in Linux, UNIX and Windows system administration, Hardware, Storage and Data center. I'm blogging since 2008.
Follow Me On Twitter or On Facebook

4 Comments for "Setting Limits for Users in Linux"

great yaar ... super i need help on monitoring the server , can you please help me out....

Hi Prathiban this is very useful post; I need to allocated and restrict an organization and the users in in it using the hard disk space in the business scenario can you help me in this regard.

Hi Venkata,

You need to use disk quota. Check out this.

What do you think about this Article? Add your Opinion..!

Back To Top