Linux increase the maximum number of open files or file descriptors
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.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Can’t re-open pipe to command substitution (fd 4): No child processes error and solution
- FTP Maximum number of clients exceeded error and solution
- Making changes to /proc filesystem permanently
- Squid Proxy WARNING! Your cache is running out of filedescriptors error and solution
- Linux Iptables ip_conntrack: table full, dropping packet error and solution
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: linux_file-max, maximum_number, open_files, processes, proc_file_system, shell, syctl_command, ulimit_command



October 21st, 2006 at 2:35 am
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
June 23rd, 2007 at 12:25 pm
Does this command work for Debian and does it affect SQUID file descriptor too?
Best Regards?
August 15th, 2007 at 6:07 pm
Maroon,
Yes it works on Debian and all other Linux systems/distros.
August 28th, 2007 at 11:40 pm
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
September 11th, 2007 at 11:34 pm
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.
September 13th, 2007 at 2:10 pm
/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.
September 13th, 2007 at 8:55 pm
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).
September 14th, 2007 at 4:32 am
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.
December 1st, 2007 at 1:54 am
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
April 23rd, 2008 at 2:23 am
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?