All about resource limits that can be set with the ulimit command
Limits can be set for each process individually. Processes inherit their limits from their parents. One distinguishes between soft and hard limits. Hard limits can be increased only by privileged processes, i.e. by processes that have superuser privileges or at least the capability
CAT_SYS_RESOURCE. Hard limits can be decreased by any process without special privileges. Soft limits can be changed arbitrarily with the constraint that the according hard limit cannot be exceeded.
Warning Resource limits are not a security mechanism. In particular, resource limits are only moderately effective against denial of service attacks by resource exhaustion. Since resource limits are individual to processes, they cannot be used to limit the resource consumption for all processes of an individual user or a group of users. (There are exceptions to this, see below). Instead, control groups should be used to enforce per-user total limits.
There are the following resource limits:
- the maximum virtual memory size
- the maximum size of the data segment
- the maximum size of the process stack
- the maximum core file size
- the maximum amount of memory that can be locked into RAM
- the maximum amount of memory that can be resident in RAM
- the maximum amount of time the process can occupy the CPU
- the maximum priority that can be assigned to a process
- the maximum number of processes with the same real user ID may be run concurrently
- the maximum number of signals that can be queued for the process
Linux has also limits for real time priorities
File and IPC limits
- The maximum number of files a process can have open simultaneously
- The maximum number of locks a process can lease
- The maximum size of files a process can create
- The maximum pipe buffer size (this limit is a somewhat special since it is set with the
fcntl()system call whereas all other limits are set with
- The maximum number of bytes that all processes with the same real user ID may allocate for POSIX message queues
Use disk quota to limit the maximum space a user can occupy on a filesystem.