Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 (

share|improve this answer

Your Answer


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.