do changes in /etc/security/limits.conf require a reboot before taking effect?

Like if I have a script that sets the following limits in /etc/security/limits.conf, does this require me to reboot the system before those limits will take effect?

* hard nofile 94000
* soft nofile 94000
* hard noproc 64000
* soft noproc 64000
  • 2
    logout should be enough – UVV Jan 9 '14 at 18:59
  • Edit the file /etc/security/limits.d/90-nproc.conf and reboot you system – user80746 Aug 13 '14 at 17:48
up vote 97 down vote accepted

No but you should close all active sessions windows. They still remember the old values. In other words, log out and back in. Every remote new session or a local secure shell take effect of the limits changes.

  • 16
    What if I want to set the limits for a user that doesn't have a login, like if I want to set the nofile limit to 94000 for the mongodb user? How'd I do that without a reboot? Would I just need to restart the mongodb service? – Alexej Magura Jan 9 '14 at 19:35
  • 2
    @AlexejMagura You can modify the the rlimits of running processes with the prlimit command. – Bratchley Jan 9 '14 at 23:46
  • 7
    @Gilles, thanks for the precisions, I edited my answer to to avoid ambiguity. However Starting a new service using sudo service mongodb restart is enough to let the service running with the new limit values. – Slyx Jan 10 '14 at 15:01
  • 6
    if you are using Ubuntu, and mongodb is started by upstart, then changing these limits will not affect mongodb. As upstart does not read /etc/security config bugs.launchpad.net/ubuntu/+source/upstart/+bug/938669 you must set limit stanza in its upstart config file. – HVNSweeting Jan 19 '15 at 3:22
  • 5
    It's another issue. upstart by design ignores the limits set in /etc/security/limits.conf. – Slyx Jan 20 '15 at 11:00

Apply the changes directly to a running process if you have prlimit installed (comes with util-linux-2.21)

prlimit --pid <pid> --<limit>=<soft>:<hard>

for example

prlimit --pid 12345 --nofile=1024:2048

Refer here

To temporarily set the open files limit for the user you are currently logged in under (e.g. 'root'):You can also use the ulimit command to change the values in your current shell. However, hard limits can only be adjusted downwards unless you're root.

Example:

# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 62449
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

To change the nofile to 94000 you can do:

ulimit -n 94000

Limits are inherited from a parent process to its child processes. Processes running as root can change limits arbitrarily; other processes cannot increase hard limits. Thus the hard limits set by the login process affect all the processes in a session.

If you change /etc/security/limits.conf, this will affect all new sessions, and processes in these new sessions. It won't affect processes that are already running, nor processes started by processes that are already running.

So if you need to increase some limits, you'll have to either log out and back in, or start another session (e.g. with ssh localhost, or on another console).

To quote @Tombart's answer

These limits will be applied after reboot.

If you want to apply changes without reboot, modify /etc/pam.d/common-session by adding this line at the end of file:

session required pam_limits.so

protected by Community Feb 22 '15 at 15:58

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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