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

How can lsof report more open files than what ulimit says is the limit?

prod_web3(i-ca0b05aa):~$ sudo lsof | wc -l
prod_web3(i-ca0b05aa):~$ ulimit -n
share|improve this question
up vote 4 down vote accepted

From the ulimit builtins man page

The ulimit builtin provides control over the resources available to the shell 
and to processes started by it on systems that allow such control.

Your lsof command lists all of the open files for all processes for all users on the system. You are not comparing like with like.

share|improve this answer

A bash(1) builtin, ulimit defines the maximum number of open files per process.

This is not a system-wide setting in any way.

share|improve this answer

Although this is old, I wanted to ask the same question... the answer is not satisfactory in my case as this is what happens:

$ sudo su tomcat -c "ulimit -n"
$ lsof -u tomcat

I'm not entirely sure why this happened. I guess that open files from sub process are not accounted for in the parent one.

share|improve this answer
The limit set by ulimit is per process and not per user. If you want to check the number of open file handles for a given process, use lsof -p $pid – Tonin Mar 28 '14 at 15:48
@Tonin I can't remember now exactly, but I'm pretty sure there was only one (main) process. Could it be that the limit applies also to subprocesses (same ppid)? Or perhaps there is some valve configuration that starts new processes instead of sub ones in tomcat... – estani Apr 1 '14 at 16:07
The limit value is inherited by child processes. But enforcement of the limit is done per process: the parent can have 1024 open files and the child can have 1024 open files too. I'm not sure about the number of processes tomcat has when running, it might depends on installation/configuration. – Tonin Apr 1 '14 at 16:19

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.