Ulimit
Soft and Hard
The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit: an unprivileged process may set only its soft limit to a value in the range from 0 up to the hard limit, and (irreversibly) lower its hard limit. A privileged process (under Linux: one with the CAP_SYS_RESOURCE capability in the initial user namespace) may make arbitrary changes to either limit value.
Commands
| Commands | Description |
|---|---|
-t | cpu time (seconds) |
-f | file size (blocks) |
-d | data seg size (kbytes) |
-s | stack size (kbytes) |
-c | core file size (blocks) |
-m | resident set size (kbytes) |
-u | processes |
-n | file descriptors |
-l | locked-in-memory size (kbytes) |
-v | address space (kbytes) |
-x | file locks |
-i | pending signals |
-q | bytes in POSIX msg queues |
-e | max nice |
-r | max rt priority |
-N 15 | kA |
Usage
Show all limits
To list all limites, just run ulimit -a
$ ulimit -a
Or if you want to see only one specific limit, you can add the parameter without any value ulimit -[parameter]
$ ulimit -n
In a session
To set the limits for a session you only need to run ulimit with the parameter which matches the limit you want to change
$ ulimit -n 2048
Global
For chaning it globally (system wide) you have to place your changes into /etc/security/limits.conf or /etc/security/limits.d/newifle
The prefered place is to store it beneath limits.d as no update on packages will overwrite it
Lets assume, you want to change the open file limit, just add the following line
* soft nofile 2048
If you want to have it in hard state, just replace soft with hard in the config.
Now the device needs to be rebooted to apply it system wide.