Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

up vote 1 down vote accepted

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.

share|improve this answer

Can you try these lines.

    • nofile 16384

And see how it works.

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

share|improve this answer

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

ulimit -SHn 16384
share|improve this answer

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.

share|improve this answer
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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