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 wrote a small program that opens a bunch of files and played with open files limit on Ubuntu(as root). I was surprised to see that only user-level limits had effect on max number of files open.

I added this in /etc/security/limits.conf:

root hard nofile 30000
root soft nofile 30000

And set /proc/sys/fs/file-max to 20000 (sysctl -w fs.file-max=20000).

I then ran my program to open 29000 files without any problems.

Why does not system-level setting have any effect in this case?

share|improve this question
    
Have you restarted/started a new session after modifying limits.conf ? –  BatchyX May 17 '13 at 14:05
    
@BatchyX Yep, I did –  snovo May 17 '13 at 14:40

1 Answer 1

up vote 2 down vote accepted

I figured it out, to recap -

user-level limits on Linux are set in /etc/security/limits.conf (or under /limits.d dir)

system-level limits are set in /etc/sysctl.conf (immediately changed by a command like this: sysctl -w fs.file-max=20000)

In my initial test system-level limit of open files was ignored because I was running my program as root , so it was a privileged process and privileged processes on Linux bypass all kernel permission checks (http://linux.die.net/man/7/capabilities)

share|improve this answer

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.