Changing Max Open File Linux


Make sure you understand this simple logic about controlling max. number of open files under Linux. If you still remember your RHCE Training, then you should be remembering sysctl.conf file.

There are two levels of control on Linux maximum number of open files (or file descriptors).

1. System Limit – which is controlled by /etc/sysctl.conf 
2. Per-User/Group/Process Limit – which can be controlled by /etc/security/limits.conf 

You may make changes by either issuing commands online or modifying the configuration files. Just remember that, online modification is usually temporary (the settings will be gone after reboot of system), change by modifying the configuration files is permanent.

Changing System wide settings:

1. Check the current value by using – cat /proc/sys/fs/file-max
2. Change it for current session – echo “372054” > /proc/sys/fs/file-max
3. Change it permanent – edit /etc/sysctl.conf and append a directive
fs.file-max = 372054
4. Execute the command – sysctl -p

Changing Per User/Group/Process settings:

1. Check the current limit by using the command – ulimit -n
2. You can change the value online by issuing the command –
ulimit -n 1025
3. For making the changes permanent you need to edit the /etc/security/limits.conf file.

Here is a small illustration from my machine.

Controlling max open files in Linux

Controlling max open files in Linux