modify and apply limits.conf without reboot

Changes made by ulimit command:

$ ulimit -n 4096
$ ulimit -Hn 16384

will apply only for current user and session. In order to make it permanent, you have to modify /etc/security/limits.conf by adding your limits:

* soft nofile 4096
* hard nofile 16384

However, wildcard * won't apply for root user. In order to do so, you have to state it explicitly:

* soft nofile 4096
* hard nofile 16384
root soft nofile 4096
root hard nofile 16384

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

Upon next login you should see updated limits, you can check them (soft and hard limits):

$ ulimit -a
$ ulimit -Ha

If you're using bash, ulimit -n will only display the soft limit. To get the hard limit, you need to do ulimit -Hn.

On my system, I see this:

$ ulimit -n
1024
$ ulimit -Hn
4096

Tags:

Linux

Ulimit