I'm tuning the nofile value in /etc/security/limits.conf for my oracle user and I have a question about its behavior: does nofile limit the total number of files the user can have open for all of its processes or does it limit the total number of files the user can have open for each of its processes?

Specifically, for the following usage:

oracle                  hard    nofile                  65536

1 Answer 1


Most of the values¹ in limits.conf are limits that can be set with the ulimit shell command or the setrlimit system call. They are properties of a process. The limits apply independently for each process. In particular, each process can have up to nofile open files. There is no limit to the number of open files cumulated by the processes of a user.

The nproc limit is a bit of a special case, in that it does sum over all the processes of a user. Nonetheless, it still applies per-process: when a process calls fork to create a new process, the call is denied if the number of processes belonging to the process's euid is would be larger than the process's RLIMIT_NPROC value.

The limits.conf man page explains that the limits apply to a session. This means that all the processes in a session will all have these same limits (unless changed by one of these processes). It doesn't mean that any sum is done over the processes in a session (that's not even something that the operating system tracks — there is a notion of session, but it's finer-grained than that, for example each X11 application tends to end up in its own session). The way it works is that the login process sets itself some limits, and they are inherited by all child processes.

¹ The exceptions are maxlogins, maxsyslogins and chroot, which are applied as part of the login process to deny or influence login.

  • 1
    Conversely, does that mean different sessions can have different sets of limits? Aug 16, 2015 at 7:21
  • 2
    @CMCDragonkai Yes, for example if limit.conf changed between the times the sessions were open, or if different limits (they'd have to be smaller except for root) are set in .profile. Aug 16, 2015 at 8:39
  • 1
    hi @Gilles'SO-stopbeingevil' so your answer explains well that nproc has total limit per Shell session, not a process. Is there an equivalent of sudo prlimit --pid 2146 --nproc=8096:1048576 per session and not per process to avoid downtime?
    – laimison
    Nov 5, 2019 at 15:07
  • 3
    @laimison If you iterate over all running processes and run prlimit --pid $pid on each, you can effectively change the limit for an active session. Note that you may have to do it a few times in case some processes are forked while you're iterating. Nov 8, 2019 at 15:58
  • 1
    @laimison No. Suppose that a user has only two processes A and B, with RLIMIT_NPROC set to 2 in A and to 3 in B. Then B can fork one more process, but A cannot. Nov 28, 2019 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.