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

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

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

* hard nofile 94000
* soft nofile 94000
* hard nproc 64000
* soft nproc 64000
Asked By: Alexej Magura

||

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.

Answered By: Slyx

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 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
Answered By: Boogy

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

Answered By: Ram

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
Answered By: serv-inc
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.