4

I have added 2 lines in

/etc/security/limits.conf

myuser soft nofile 16384
myuser hard nofile 16384

...which has no effect:

su -
sysctl -p
su myuser
ulimit -n
1024

It is important that this comes into effect without the user having to log in first, i.e. as root I start a script on his behalf.

recalcitrant
  • 153
  • 1
  • 3

4 Answers4

2

Add this to /etc/security/limits.conf:

*               soft    nofile          16384
*               hard    nofile          16384

And add something like this to /etc/profile and it should apply system wide to all accounts:

ulimit -n 16384

However in order for tools such as ssh and su to obey the limits.conf file you need to add the following to the corresponding pam.d files if it's not yet there, i.e. for su add to /etc/pam.d/su and for ssh add to /etc/pam.d/sshd:

session    required     /lib/security/pam_limits.so

I believe your particular problem may be solved just by doing the pam.d edit above to the appropriate files.

aseq
  • 4,610
  • 1
  • 24
  • 48
0

Can you try these lines.

    • nofile 16384

And see how it works.

Is there any setting in users .bashrc or other files.

Soham Chakraborty
  • 3,584
  • 17
  • 24
0

If everything else fails, would your script allow to do as myuser the following:

ulimit -SHn 16384
Janne Pikkarainen
  • 31,852
  • 4
  • 58
  • 81
0

If the changes in /etc/security/limits.conf seems to have no effect, check if /etc/security/limits.d/ contains files with limit settings that override yours.

If you need to override a limit that is configured in a file located in /etc/security/limits.d/, it's probably better to create your own file in that directory, with a name that sorts alphanumerically later than the existing file. The system reads the files in alphanumerical order, and if there are multiple configurations for the same limit, the later settings will override earlier ones.

telcoM
  • 1
  • 1
    The answer of @aseq is clear on this: one should actually apply current limits by asking for it using `ulimit`. The `limits.conf` file defines only hard/soft limits, not defaults. Suggestion to use the `.d` directory is good, though. – gertvdijk Dec 13 '12 at 13:20