/etc/security/limits.conf, verify them, and understand each directive.
Prerequisites
- A Linux distribution with PAM-enabled login (most modern distros).
sudoprivileges to edit/etc/security/limits.conf.
1. Back Up and Open limits.conf
Always back up system configuration files before editing.
2. Understanding limits.conf Fields
limits.conf uses four fields per line:2.1 Domain
username(e.g.,trinity)- Group with
@prefix (e.g.,@developers) *for every user not otherwise matched
trinity to 10 processes:
2.2 Type
hard— absolute maximum (cannot be exceeded).soft— initial/session limit (can increase up to hard).-— sets bothsoftandhard.
2.3 Item
Resource items you can limit:
Example: file-size and CPU restrictions for
trinity:
3. Exercise: Enforce a 3-Process Limit for “trinity”
-
Add the following (uncommented) line to
/etc/security/limits.conf: - Save and exit.
3.1 Verify the Limit
3.2 Check with ulimit
Changes take effect on new sessions. Log out and back in to apply updates.
Use
Use
ulimit -a to inspect all current limits.