Q. How do I increase the maximum number of open files under CentOS Linux? How do I open more file descriptors under Linux?
A. ulimit command provides control over the resources available to the shell and to processes started by it, on systems that allow such control. The maximum number of open file descriptors displayed with following command (login as the root user).
Command to list umber of open file descriptors
Use the following command command to display maximum number of open file descriptors:
cat /proc/sys/fs/file-max
Output:
75000
75000 files normal user can have open in single login session.
The number of maximum files was reached, how do I fix this problem?
Many application such as Oracle database server needs this range quite higher. So you can increase the maximum number of open files by setting new value in kernel variable /proc/sys/fs/file-max as follows (login as the root):
# sysctl -w fs.file-max=100000
Above command forces the limit to 100000 files. You need to edit /etc/sysctl.conf file and put following line so that after reboot the setting will remain as it is:
# vi /etc/sysctl.conf
Append a config directive as follows:
fs.file-max = 100000
Save and close the file. Users need to log out and log back in again to changes take effect or just type command:
# sysctl -p
Verify your settings with command:
# cat /proc/sys/fs/file-max
OR
# sysctl fs.file-max
Updated for accuracy.
- Email FAQ to a friend
- Printable version
- Rss Feed
- Last Updated: 9-21-07

{ 11 comments… read them below or add one }
Icreasing the file handles is a good tip, but 5000 is very low these days. 200000 is more realistic for any modern system.
Also, there’s no need to logout, just edit the /etc/sysctl.conf and then type ’sysctl -p’ as root.
Thanks,
Tachyon
Does this command work for Debian and does it affect SQUID file descriptor too?
Best Regards?
Maroon,
Yes it works on Debian and all other Linux systems/distros.
how to increase in a Redhat linux server? How to find the location of sysctl.conf file or how to find in which file the limit has been set?
thanks in advance
i tried this on a CentOS (which by the way, i’ve decided the worst linux distribution ever), and it doesn’t seem to work. ulimit -n still says 1024, even after logout, even after reboot.
/etc/sysctl.conf is good for the system-wide amount, but don’t forget that users also need different limits. See /etc/security/limits.conf (Debian, Redhat, SuSE all have it, probably most others as well) to assign specific limits on per-group, per-user, and default basises.
I am running “Red Hat Enterprise Linux ES release 4 (Nahant Update 5)” and followed the instructions above. Like “baka.tom”, I was unable to see the change reflected by typing “ulimit -n”. I don’t know if this is a problem, but it certainly reduces the credibility of this article (unless I screwed up, of course).
baka.tom / jason,
The FAQ has been updated for latest kernel. It should work now. Let me know if you have any more problems.
bourne, thanks for pointing out user level or group level filelimit option.
I appreciate all feedback.
Red Hat configuration requires the following line to be added for /etc/security/limits to work.
in /etc/pam.d/login
session required pam_limits.so
I’m trying to make 8192 on Ubuntu 7.10, adding
* soft nofile 8192
* hard nofile 8192
doesn’t work, but when i do change * to username(lets say root) it applies.
So how to change it system wide?
you could use the following command to check if the given change reflected
#ulimit -n -H
that gives the hard value…