Linux Know-How provides a collection of introductory texts on often needed Linux skills.

Number of opened files reached

The latest versions of Linux kernel implement a dynamic limit on the maximum number of opened files.

With an older system, you can increase the limit on the number of opened files using the /proc file system. This file system is entirely virtual--it is just a "window" to see or set some parts of the Linux kernel. To read the maximum number of simultaneously opened files on my system, I use the following command:

cat /proc/sys/fs/file-max

On my system (Mandrake 7.2), the limit is 8192. To increase it, I use (as root):

echo 16000 > /proc/sys/fs/file-max

You may also want to increase the limit on a related kernel variable:

echo 30000 > /proc/sys/fs/inode-max

To make the changes permanent, add the above lines at the end of your startup script /etc/rc.d/rc.local

To find out how many files are currently opened on my running system, I may run (as root):

/usr/sbin/lsof |wc -l

This runs a utility that lists opened files ("lsof") and pipes the output to a utility wordcount ("wc") telling it to count lines of output (option "-l").

To learn more about the /proc Linux kernel interface, the meaning of the variables it contains, and their recommended values, you may wish to read (if you installed the Linux kernel source codes, which is a great resource even for a newbie):

less /usr/src/linux/Documentation/proc.txt

or (on RedHat 8.0)

man proc

Last Update: 2010-12-16