Increase the number of open files under Linux

Posted on December 11, 2013 at 6:42 pm

Display maximum number of open file descriptors:

cat /proc/sys/fs/file-max

Display hard and soft values:

ulimit -Hn
ulimit -Sn

Display hard and soft values for a specific user:

su - username

System-Wide File Descriptors Limits

To increase the maximum number of open files until reboot, type:

sysctl -w fs.file-max=150000

To permanently increase the maximum number of open files, edit sysctl.conf file:

vi /etc/sysctl.conf

Append the following line:

fs.file-max = 150000

Then type the following command for changes to take effect:

sysctl -p

To verify your settings type:

cat /proc/sys/fs/file-max

Or alternatively type:

sysctl fs.file-max

User Level File Descriptors Limits

Edit the file limits.conf:

vi /etc/security/limits.conf

To change the soft and hard limits for all users except for user root:

*               soft     nofile           150000
*               hard     nofile           150000

To change the soft and hard limits also for user root:

root            soft     nofile           150000
root            hard     nofile           150000

To change the soft and hard limits for user httpd:

httpd            soft     nofile           150000
httpd            hard     nofile           150000

Then reboot the system:

shutdown -r now

Updated on February 18, 2014 at 10:11 am

Receive updates via email

Other Posts

Updated Posts