Modify the maximum number of files that can be opened in Linux

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.