Home  >  Article  >  Operation and Maintenance  >  Share how to modify the limit on the maximum number of open files in Linux

Share how to modify the limit on the maximum number of open files in Linux

黄舟
黄舟Original
2017-10-14 11:03:471955browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn