Home >Operation and Maintenance >Linux Operation and Maintenance >Share how to modify the limit on the maximum number of open files in Linux
This article mainly introduces you to the method of modifying the limit of the maximum number of open files in Linux. The article introduces the implementation method step by step in very detail. It has certain reference and learning value for friends who also encounter this need. Friends who need it, please follow the editor to learn together.
Preface
This article mainly introduces the relevant content about the modification of the maximum number of open files in Linux, and shares it with you. For reference and study, there is not much to say below, let’s take a look at the detailed introduction:
Linux will have a limit on the maximum number of files that can be opened for each user logging into the system. This limit is passed through ulimit -n
As you can see, it is usually 1024.
In some concurrency or multi-thread situations, this limit needs to be exceeded.
Modify
The first step is to edit /etc/security/limits.conf and make sure it contains the following lines:
* soft nofile 65535 * hard nofile 65535
Here * means all users, but Some systems do not recognize it and require a specific user name, such as:
root soft nofile 65535 root hard nofile 65535
The second step is to edit etc/pam.d/login and make sure there are the following lines:
session required pam_limits.so
The third step is to exit the terminal and log in again.
Verification
Use The ulimit -Hn
and ulimit -Sn
commands can respectively view the hard and soft limits of the current process user.
Or after the current user starts a program, pass cat /proc/bed08b0deaa559fa022c3f83f9c03e86/limits
(pid is the process, or the pid of any of its sub-processes)
Summary
The above is the detailed content of Share how to modify the limit on the maximum number of open files in Linux. For more information, please follow other related articles on the PHP Chinese website!