Modify the maximum number of files that can be opened in Linux
1. Modify the target
Our goal is to set the maximum number of files opened by the system after every Linux user logs on to the system.
However, I have to say this: unfortunately, there are many articles on the Internet about setting and modifying resource limits for ulimit, but none of them works.
This goal is divided into two goals:
1.1 set to take effect for the root user to log on to the system
This goal can be achieved easily.
1.2. The setting takes effect for all users
This is very troublesome. If this problem is not solved, your system will be damaged, because you need to re-compile the Linux kernel!
So in balance, I only achieved the first goal, because the risk of the second goal is too high. I think if I knew this before, I will do this first when installing the system, but now I think it's too late.
2. Modified location
2.1. Modify/etc/security/limits. conf.
Use vi/etc/security/limits. conf to modify the content and add it to the end of the file (the value can also be customized ):
* Soft nofile = 65536
* Hard nofile = 65536
Root soft nofile 65536
Root hard nofile 65536
* Indicates that the configuration is valid for all users. The root user must add two lines.
2.2. Modify/etc/profile.
Modify through vi/etc/profile and add the following content at the end
Ulimit-n 65536
Then you can log on again to make the change take effect.
Note:
In fact, only modification to/etc/profile takes effect, but I suggest modifying/etc/security/limits. conf.
Finally, it is emphasized that if you want to make the modification take effect for all users, you can only re-compile the Linux kernel.
This article permanently updates the link address: