3

I followed this answer: https://askubuntu.com/a/162230

I edit limits.conf, now it is

* soft nofile 65536
* hard nofile 65536
* soft nproc  65536
* hard nproc  Unlimited
root soft nofile 65536
root hard nofile 65536

Also, I edit both "/etc/pam.d/common-session" and "/etc/pam.d/common-session-noninteractive". Add the line at the end of both files:

session required pam_limits.so

And I restarted the Ubuntu, but "prlimit" still shows

NOFILE  ... 1024  65536 files

ulimit -n also shows 1024

How could I change this permanently?

Ryan
  • 33

3 Answers3

3

The easiest way to change this is to put ulimit -S -n 65536 in your shell init file (.bashrc possibly).

user10489
  • 5,533
0

I think this is a bug.

I also cannot change these values, even if I specify to systemd LimitNOFILE as a user setting or as a system setting, dependant services crash because of nofile limits being 1024 irrespective of the settings in limits...

To work around it, I forced the limit as root user to 65535 using ulimit... It needs to be applied each boot.

0

I followed the below instructions to permanently set ulimit -n which controls the number of open files in ubuntu:

set ulimit
# available limit
user@ubuntu:~$ ulimit -n
1024

To increase the available limit to say 65535

user@ubuntu:~$ sudo vim /etc/sysctl.conf

add the following line to it

fs.file-max = 65535

sudo vim /etc/security/limits.conf

add following lines to it

  • soft nproc 65535
  • hard nproc 65535
  • soft nofile 65535
  • hard nofile 65535

root soft nproc 65535
root hard nproc 65535
root soft nofile 65535
root hard nofile 65535

edit the following file

user@ubuntu:~$ sudo vim /etc/pam.d/common-session

add this line to it

session required pam_limits.so

run this to refresh with new config

user@ubuntu:~$ sudo sysctl -p

logout and login and try the following command

user@ubuntu:~$ ulimit -n 65535

It is important to increase the limit, i.e. the max value 65536.
But I also needed these steps:

For me it helped to adjust the /etc/systemd/system.conf and the /etc/systemd/user.conf.

[Manager] DefaultLimitNOFILE=65536

After that, just reload with

sudo systemctl daemon-reexec

then it worked. Maybe this will help someone.