tags : Linux
What is it?
- A shell builtin that works on a per-process basis. Limit is then adopted by the shell that called it and inherited by children(i.e children will have their own limits, number will be same though).
- The shell builtin essentially wraps
getrlimit/setrlimitsystem calls. - Option in container tools like docker, podman. i.e it’ll set ulimit for the container sort of.
- TODO:
ulimitin containers is tricky, I’ve to check it properly when I get time. I mean it’s used slightly differently andnprochas some host specific things etc. Little complicated.
- TODO:
What about process?
- Once a process starts, its ulimits are set. The process itself can change its
soft ulimitup to thehard ulimit. prlimitcan help you change ulimits of running process
Relationship w limits.conf
Limits are a property of a process.
About limits.conf
- The file does not affect system services.
/etc/security/limits.conffile provides configuration for thepam_limitsPAM module/etc/security/limits.confallows setting resource limits for users and groups logged in via PAM.- However
/etc/security/limits.confdoes not workfor the systemusingsystemd. Following needs to be changed instead./etc/systemd/system.conf/etc/systemd/user.conf/etc/systemd/system/unit.d/override.conf
Types of limits
- Hard limits
- Set by
rootand enforced by the kernel. - Mark the
maximum valuewhich cannot be exceeded by setting a soft limit.
- Set by
- Soft limits
- Configured by the user within the range allowed by the hard limits.
- Simply the currently enforced limits.
System and User limits
Limits are inherited when a child process is created
- System wide limits
- Should be set during the system initialization in init scripts, systemd specific conf files etc.
- User limits
- Should be set during user login for example by using
pam_limits(/etc/security/limits.conf)
- Should be set during user login for example by using