7

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?

diolemo
  • 283
  • 1
  • 2
  • 7

5 Answers5

3

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.

Danila Ladner
  • 5,241
  • 21
  • 30
2

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

Hawkeye
  • 21
  • 1
1

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.

estani
  • 2,011
  • 2
  • 17
  • 12
1

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.

Czarek
  • 11
  • 1
0

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