About Linux FAQ

Browse More FAQs:

Linux increase the maximum number of open files or file descriptors

Posted by Vivek Gite [Last updated: September 21, 2007]

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:

Discussion on This FAQ

  1. Tachyon Says:

    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

  2. Maroon Ibrahim Says:

    Does this command work for Debian and does it affect SQUID file descriptor too?
    Best Regards?

  3. vivek Says:

    Maroon,

    Yes it works on Debian and all other Linux systems/distros.

  4. Sathish A Says:

    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

  5. baka.tom Says:

    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.

  6. bourne Says:

    /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.

  7. jason Says:

    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).

  8. vivek Says:

    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.

  9. jackson Says:

    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

  10. Arstan Says:

    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?

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!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , ,

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.