Jump to Navigation

167 - file-max in Linux

The file-max file /proc/sys/fs/file-max sets the maximum number of file-handles that the Linux kernel will allocate.
We generally tune this file to improve the number of open files by increasing the value of /proc/sys/fs/file-max to
something reasonable like 256 for every 4M of RAM.

1.The command forces the limit to 200000 files.

# sysctl -w fs.file-max=200000

2. After the above, need to edit /etc/sysctl.conf file so that the next reboot will remain as it is.

# vi /etc/sysctl.conf

fs.file-max = 200000

3. Users need to log out and log back in again to changes it (or just type the following command.).

# sysctl -p

4. Verify your settings.

# sysctl fs.file-max

# cat /proc/sys/fs/file-max


The above procedure sets system-wide file descriptors (FD) limits. However, you can limit httpd (or any other users) user to
specific limits by editing /etc/security/limits.conf file :

httpd soft nofile 4096
httpd hard nofile 10240

To see the hard and soft values, issue the command as follows:

# su - httpd
# ulimit -Hn
# ulimit -Sn


Main menu 2

Story | by Dr. Radut