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

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

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

Method 3

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

Method 4

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).

Method 5

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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x