Setting User Limits
In a large installation, it is sometimes difficult to keep control of user activities. Some user programs can use excessive resources, to the detriment of other users. This is particularly true in universities and colleges, where student’s activities can leave few resources for programs run by staff. Also some services automatically grab as many resources as they find available at run time, leaving few resources for subsequent programs. Resources include disk space, memory, CPU time and I/O requests.
It can be useful, therefore, to set limits for each user or group of users. The /etc/security directory holds files that can be used to limit user activities. The most important of these files is /etc/security/limits.conf. It holds entries in the following format:
<domain> <type> <item> <value>
where
<domain> is the name of the user or group (groups must be prefixed with @)
<type> is either ‘hard’ or ‘soft’
<item> is one of the items listed below
<value> is the value required
Items include:
core - limits the core file size (KB)
data - maximum data size (KB)
fsize - maximum filesize (KB)
memlock - maximum locked-in-memory address space (KB)
nofile - number of open files
rss - max resident memory set size (KB)
stack - stack size (KB)
cpu - maximum CPU time
nproc - maximum number of processes
as - address space limit
maxlogins - maximum number of logins for this user
priority - the priority used for user processes
locks - maximum number of file locks
When setting these limits, you should check the documentation of any software packages that you are running, to ensure that they are able to run within the limits that you have set.
Another useful file in this directory is /etc/security/access.conf, which is used to control which users are allowed to log in from which sources. For example, it is possible to restrict a user’s access to one particular terminal, or to prevent users from logging in via the network.
This file holds entries in the format:
<permission>:<user_or_group>:<origin>
where
<permission> can be + or -
<user_or_group> A user name, group name, or ALL, or ALL except user or group name
<origin> A TTY number, host name or domain name