sexta-feira, 3 de agosto de 2012

How to use limits.conf on Linux

How to use limits.conf on Linux:

Sometimes you need to increase the open file limit for some application server or the maximum shared member for you ever-growing master database. In such a case you edit your /etc/security/limits.conf and then wonder how to get the changed limits to be visible to check wether you have set them correctly. You do not want to find out that they were wrong after your master DB doesn't come up after some incident in the middle of the night...

The best way is to change the limits and check them by running
ulimit -a

with the affected user.

But often you won't see the changes. The reason: you need to re-login as limits are only applied on login!
But wait: what about users without login? In such a case you login as root (which might not share their limits) and sudo into the user: so no real login as the user. In this case you must ensure to use the "-i" option of sudo:
sudo -i -u <user>

to simulate an initial login with sudo. This will apply the new limits.
A last alternative is modifying the PAM behaviour. On most Linux distributions PAM will load "pam_limit.so" in /etc/pam.d/login which means at login time. By adding this
session    required   pam_limits.so

Nenhum comentário:

Postar um comentário