Take the 2-minute tour ×

I'm looking for a way to find out the open FD limit under Ubuntu machines which doesn't have the /proc/PID/limits, namely EC2 machines.

I have been looking into /proc/PID/limits, and found the the entry FDSize with values like:

FDSize: 256
FDSize: 512

Any way I can deduce the maximum allowed open file descriptors from this value?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

No, it does not show the limit - just the usage.

>>> import resource
>>> resource.setrlimit(resource.RLIMIT_NOFILE, (10000, 10000))
>>> resource.getrlimit(resource.RLIMIT_NOFILE)
(10000, 10000)


>>> for i in range(5000):
...     f=open('/tmp/delme'+str(i),'w')
...     fs.append(f)


laptop:/proc/20160$ cat status
FDSize: 8192

The value wasn't changed after changing the limit, just after creating the files. It means that it measures the actual usage, not the limits.

share|improve this answer

Afaik, on Linux the per-process limit of open files is controlled via the ulimit command. From man ulimit:

    ulimit - set or report file size limit

    The  ulimit utility shall set or report the file-size writing limit 
imposed on files written by the shell and its child processes (files 
of any size may be read). Only a process with appropriate privileges 
can increase the limit.

On my system:

$ ulimit -aS | grep "open files"
open files                      (-n) 1024

$ ulimit -aH | grep "open files"
open files                      (-n) 1024

The system-wide limit is stored in /proc/sys/fs/file-max

$ cat /proc/sys/fs/file-max

The The Linux HTTP Benchmarking section on tuning file descriptor limits on Linux has more info.

I'm not entirely clear if this is exactly what you were looking for. Does this answer your question?

share|improve this answer

from man proc, "* FDSize: Number of file descriptor slots currently allocated.", this is the number of "struct file" in the file descriptor table of a process.

share|improve this answer

Your Answer


