How to Increase Open Files Limit in Ubuntu & Debian

Check for Current Limits

The ulimit command provides control over resources available to each user via a shell. You can use below command to
to get the current settings.

ulimit -a

To view the current hard limit or soft limit use the following command.

ulimit -Sn       # Check soft limit
ulimit -Hn       # Check hard limit

Increase Limit for Current Session

Most operating systems can change the open-files limit for the current shell session using the ulimit -n command:

ulimit -n 200000

Increase per-user Limit

You can define per-user open file limit on a Debian based Linux system. To set per-user limit, edit /etc/security/limits.conf file in a text editor.

sudo vim /etc/security/limits.conf

Add the following values in file:

* 	 soft     nproc          65535
* 	 hard     nproc          65535
* 	 soft     nofile         65535
* 	 hard     nofile         65535
jack 	 soft     nproc          200000
jack 	 hard     nproc          200000
jack 	 soft     nofile         200000
jack 	 hard     nofile         200000

Here we specifying separate limits which are 200000 for the user “jack” and 65535 will be applied for the rest of the users. You can change these values per your requirements.

After that enable the pam_limits as followings:

sudo vim /etc/pam.d/common-session

Add the following line:

session required pam_limits.so

Increase system-wide Limit

You can also set the limits system-wide by editing the sysctl configuration file. Edit sysctl.conf file:

vim /etc/sysctl.conf 

Add the following line:

fs.file-max = 2097152

Then run the following command to apply the above changes:

sysctl -p

The above changes will increase the maximum number of files that can remain open system-wide. The specific user limit can’t be higher than the system-wide limit.

Was this answer helpful?

Related Articles

How to Enable CSF Firewall Web UI

Step 1 – Install Required Perl Modules: CSF UI required some of Perl modules to be installed...

How to Install and Configure CSF Firewall on Linux

Step 1: Download CSF Source Archive Download latest CSF archive source code from its official...

How To Install mod_cloudflare for Apache on Ubuntu

Install mod_cloudflare for Apache First of all, enable the PPA of Cloudflare module to your...

How To Install Wine 4.0 on CentOS 8 & Fedora 30/29

Step 1 – Prerequisite First of all, become root user on your CentOS 8 system. Then continue to...

How to Install Fail2Ban on CentOS 8 & Fedora 30/29

Step 1 – Install Fail2ban on CentOS 8 First of all, install epel-release package to configure...