How to change “open files” in Linux

I will give an example of viewing and increasing the value of “open files” in Linux.

Let’s see the current value (it is 1024 by default):

ulimit -n
ulimit -a
cat /proc/sys/fs/file-max
cat /proc/sys/fs/file-nr

Let’s look at the Hard and Soft limits (you can look under other users by switching to them su user):

ulimit -Hn -Sn

If you need to increase, for example, execute:

ulimit -n 65535

To prevent the value from being reset after the system is restarted, we will add to the /etc/security/limits.conf file (you can also specify limits for different users individually):

* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535

To increase fs.file-max (before rebooting):

sudo sysctl -w fs.file-max=3278811

Or:

echo "3278811" > /proc/sys/fs/file-max

To prevent the value from being reset after a system restart, you can add to /etc/sysctl.conf:

fs.file-max=3278811

Apply the change:

sudo sysctl -p

See also my articles:
How to change open_files_limit in MySQL
Samba warning solution “rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)”

Did my article help you? How about buying me a cup of coffee as an encouragement? Buy me a coffe.

Leave a comment

Leave a Reply