Ubuntu 20.04 increase max open files limit

ulimit is a Linux shell command to see, set, or limit the resource usage.

root@poloon:~# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 127260
max locked memory       (kbytes, -l) 65536
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 127260
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

add the following line to end of /etc/security/limits.conf

*    soft nofile 65536
*    hard nofile 65536
poloon soft nofile 65536
poloon hard nofile 65536
root soft nofile 65536
root hard nofile 65536

add session required pam_limits.so to /etc/pam.d/common-session and /etc/pam.d/common-session-noninteractive

add DefaultLimitNOFILE=65536 to /etc/systemd/user.conf

add fs.file-max = 65536 to /etc/sysctl.d/60-file-max.conf

Leave a Comment

Your email address will not be published. Required fields are marked *