I have the following lines in /etc/security/limits.conf

*           soft        nofile          32768
*           hard        nofile          65536
root        soft        nofile          32768
root        hard        nofile          65536

The pam_limits.so file is required in each of the following files.

/etc/pam.d/common-session
/etc/pam.d/cron
/etc/pam.d/login
/etc/pam.d/sshd
/etc/pam.d/su
/etc/pam.d/sudo

ulimit -n upon login (and for services that are started upon bootup) shows 1024 still.

What am I missing?

For services in init.d you cannot use /etc/security/limits.d inittab is not reading that files and it is based on pam.d which is not used in initialization startup scripts. All init startup scripts source /etc/init.d/functions so for all services you could hack that script and set limits there. I used to hack /etc/sysconfig for particular services when I needed {httpd, some brokenass oracle stuf} e.t.c. Hope this helps.

Ubuntu 14.04

Had to add both 'hard' and 'soft' entries in /etc/security/limits.conf for pam to recognize settings for rtprio (-r) and memlock (-l).

  • This solved my issue in RHEL 7.1. Thanks! – GrkEngineer Aug 3 '17 at 15:52

have you checked you don't have other config files in /etc/security/limits.d/?

Have you tried increasing it with ulimit?

$ ulimit -n 4096
$ ulimit -n
4096

And after saving you must log in again. It's not enough to start a shell, it must be a login shell.

If you are root, execute the command below

 ulimit -SHn 65535

If you want to set it permanently, especially for a particular user, change the file /etc/security/limits.conf to have the following lines (assume user = www-data)

E.g.

 www-data hard nofile 65535

 www-data soft nofile 65535

And make sure uncomment pam_limits.so from the different files under /etc/pam.d, e.g. sudo, login, sshd, ... after following above steps which you have already did.

Finally restart your system

Try checking /var/log/auth.log

I've found answer to my problem there. In my case the limit was not set due to an error causing the default value (1024) to be used.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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