Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)

www.la‮tu‬turi.com
Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)

To increase the maximum number of open files (also known as file descriptors or FDs) in Linux, you can use one of the following methods:

  1. Edit the "fs.file-max" kernel parameter:
  • To view the current value of the "fs.file-max" parameter, run the following command:
cat /proc/sys/fs/file-max
  • To increase the value of "fs.file-max", edit the "/etc/sysctl.conf" file and add the following line:
fs.file-max = NEW_VALUE

Replace "NEW_VALUE" with the desired value. For example, to increase the value to 100000, use the following line:

fs.file-max = 100000
  • Save the changes and apply the new value by running the following command:
sysctl -p
  1. Edit the "ulimit" setting for the user or system:
  • To view the current "ulimit" value for a user, run the following command:
ulimit -n
  • To increase the "ulimit" value for a user, add the following line to the user's "~/.bashrc" file:
ulimit -n NEW_VALUE

Replace "NEW_VALUE" with the desired value. For example, to increase the value to 100000, use the following line:

ulimit -n 100000
  • Save the changes and apply the new value by logging out and logging back in, or by running the following command:
source ~/.bashrc
  • To increase the "ulimit" value for the system, edit the "/etc/security/limits.conf" file and add the following lines:
*    soft    nofile    NEW_VALUE
*    hard    nofile    NEW_VALUE

Replace "NEW_VALUE" with the desired value. For example, to increase the value to 100000, use the following lines:

*    soft    nofile    100000
*    hard    nofile    100000
  • Save the changes and apply the new value by logging out and logging back in, or by running the following command:
ulimit -n NEW_VALUE

Note: The above methods increase the maximum number of open files for the system or user. However, the actual number of open files that a program can have is limited by the available system resources, such as memory and CPU. Additionally, the maximum number of open files may also be limited by the kernel parameter "fs.nr_open", which specifies the maximum number of file handles that the system can have at any given time.

Created Time:2017-10-30 10:17:34  Author:lautturi