Skip to content

Instantly share code, notes, and snippets.

@nastra
Last active July 20, 2023 07:41
Show Gist options
  • Save nastra/0862e033ca9f9de6e6c5 to your computer and use it in GitHub Desktop.
Save nastra/0862e033ca9f9de6e6c5 to your computer and use it in GitHub Desktop.

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

Modify **/etc/systemd/user.conf **and /etc/systemd/system.conf with the following line (this takes care of graphical login):

DefaultLimitNOFILE=65535

echo '* hard nofile unlimited' | sudo tee --append /etc/security/limits.conf echo '* soft nofile unlimited' | sudo tee --append /etc/security/limits.conf echo '* soft nproc 32768' | sudo tee --append /etc/security/limits.conf echo '* hard nproc 32768' | sudo tee --append /etc/security/limits.conf echo '* soft memlock unlimited' | sudo tee --append /etc/security/limits.conf echo '* hard memlock unlimited' | sudo tee --append /etc/security/limits.conf

For CentOS / RHEL we need to set nproc limits additionally in 90-nproc.conf

echo '* soft nproc 32768' | sudo tee --append /etc/security/limits.d/90-nproc.conf echo '* hard nproc 32768' | sudo tee --append /etc/security/limits.d/90-nproc.conf

@nastra
Copy link
Author

nastra commented Jan 17, 2018

For stuff running with systemd, the settings need to be changed in /etc/systemd/system.conf / /etc/systemd/user.conf:

DefaultLimitNOFILE=infinity
#DefaultLimitNPROC=
DefaultLimitMEMLOCK=infinity

https://unix.stackexchange.com/questions/366352/etc-security-limits-conf-not-applied

@nastra
Copy link
Author

nastra commented Aug 20, 2018

There's a bug since Ubuntu 16 apparently.

Basically:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment