Skip to main content
Managing resource usage per user prevents any single account from monopolizing CPU, memory, or processes. In this guide, you’ll learn how to configure limits via /etc/security/limits.conf, verify them, and understand each directive.

Prerequisites

  • A Linux distribution with PAM-enabled login (most modern distros).
  • sudo privileges to edit /etc/security/limits.conf.

1. Back Up and Open limits.conf

Always back up system configuration files before editing.
Open the file for editing:
You’ll see a template like:

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
Example: limit user trinity to 10 processes:

2.2 Type

  • hard — absolute maximum (cannot be exceeded).
  • soft — initial/session limit (can increase up to hard).
  • - — sets both soft and hard.

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”

  1. Add the following (uncommented) line to /etc/security/limits.conf:
  2. Save and exit.

3.1 Verify the Limit

3.2 Check with ulimit

You can adjust soft limits on the fly:
Changes take effect on new sessions. Log out and back in to apply updates.
Use ulimit -a to inspect all current limits.

4. References and Further Reading

Watch Video