4

I edited /etc/security/limits.conf to have

root hard nofile 20000
root soft nofile 10000

And added

session required pam_limits.so

to /etc/pam.d/common-session and /etc/pam.d/common-session-noninteractive.

After reboot and relogin ulimit -n still shows 1024.

If I do su and try ulimit -n again then it shows 10000. But after a relogin it goes back to 1024.

  • you don't necessarily have to reboot after changing /etc/security/limits.conf. See http://unix.stackexchange.com/questions/108603/do-changes-in-etc-security-limits-conf-require-a-reboot

    Also, I think http://serverfault.com/questions/356962/where-are-the-default-ulimit-values-set-linux-centos might answer your question.

    – Alexej Magura Dec 15 '14 at 05:03

2 Answers2

1

Check the manual: man limits.conf

That will show you that the first field in that configuration file is the <domain> or simplified: the users or groups for whom the setting is applied to. So when you use root there it's completely expected that it only works for root and not for any other user.

Try the following to apply it to all users or better find some middle ground and apply to the correct users/groups.

*     hard      nofile     20000
HBruijn
  • 7,418
  • Hey there, my goal was to increase it for the root user, I login as root and ulimit -n shows 1024, if I do su and then ulimit -n it shows 10000. – Barış Uşaklı Dec 13 '14 at 19:06
1

For RHEL and related distributions, there is now a new directory /etc/security/limits.d

The files within this directory silently override the information in the /etc/security/limits.conf file(!).

Check for 90-nproc.conf and you'll see the culprit there.

You can create new files in this directory - they are read in numeric order, so for application specific values create a file named something like 95-appname.conf and put the values required in there.

Note that any new files must have the extension '.conf' or the system will ignore them.

dr-jan
  • 554