23

I have /etc/security/limits.conf, that seems not been applied:

a soft nofile 1048576 # default: 1024
a hard nofile 2097152
a soft noproc 262144  # default 128039
a hard noproc 524288  

Where a is my username, when I run ulimit -Hn and ulimit -Sn, it shows:

4096
1024

There's only one other file in the /etc/security/limits.d that the content is:

scylla  -  core     unlimited
scylla  -  memlock  unlimited
scylla  -  nofile   200000
scylla  -  as       unlimited
scylla  -  nproc    8096

I tried also append those values to /etc/security/limits.conf then restarting, and do this:

echo '
session required pam_limits.so
' | sudo tee -a /etc/pam.d/common-session

but it didn't work. My OS is Ubuntu 17.04.

Kokizzu
  • 9,257
  • 12
  • 55
  • 82

2 Answers2

19

https://superuser.com/questions/1200539/cannot-increase-open-file-limit-past-4096-ubuntu/1200818#=

There's a bug since Ubuntu 16 apparently.

Basically:

  1. Edit /etc/systemd/user.conf for the soft limit, and add DefaultLimitNOFILE=1048576.
  2. Edit /etc/systemd/system.conf for the soft limit, and add DefaultLimitNOFILE=2097152.

Credit goes to @mkasberg.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
daniel.gindi
  • 306
  • 2
  • 4
13

An alternative for those who prefer not to edit the default /etc/systemd/system.conf and /etc/systemd/user/conf files:

  1. create a new file /etc/systemd/system.conf.d/limits.conf with these contents:

    [Manager]
    DefaultLimitNOFILE=1048576:2097152
    DefaultLimitNPROC=262144:524288
    
  2. run systemctl daemon-reexec as root

  3. logout and login again

  4. check your new limits with either ulimit -a or ulimit -n and ulimit -u for max open files and max processes, respectively.

Refer to the systemd-system.conf manpage for details.

Marc.2377
  • 1,072
  • 1
  • 17
  • 41