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/pam_limits.so.

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:

core
 Limits the size of a core file (KB).
data
 Maximum data size (KB).
fsize
 Maximum file size (KB).
memlock
 Maximum locked in memory address space (KB).
nofile
 Maximum number of open files.
rss
 Maximum resident set size (KB).
stack
 Maximum stack size (KB).
cpu
 Maximum CPU time in minutes.
nproc
 Maximum number of processes.
as
 Address space limit.
maxlogins
 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

Share this

Related Posts

Previous
Next Post »

4 comments

Write comments
October 1, 2012 at 5:53 PM delete

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

Reply
avatar
May 14, 2013 at 11:32 AM delete

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.

Reply
avatar
May 14, 2013 at 11:34 AM delete

Hi Venkata,

You need to use disk quota. Check out this.

http://www.lazysystemadmin.com/2010/03/disk-quotas-in-linux-quick-howto.html

Reply
avatar

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