18

I am trying to raise the open file descriptor maximum for all users on an ubuntu machine.

I've added the following lines to /etc/security/limits.conf:

*               soft    nofile           100000
*               hard    nofile           100000

And, based on this question I've checked the /etc/pam.conf settings for pam_limits:

$ grep "pam_limits" /etc/pam.d/*
/etc/pam.d/atd:session    required   pam_limits.so
/etc/pam.d/common-session:session required pam_limits.so
/etc/pam.d/cron:session    required   pam_limits.so
/etc/pam.d/login:session    required   pam_limits.so
/etc/pam.d/sshd:session    required     pam_limits.so
/etc/pam.d/su:session    required   pam_limits.so
/etc/pam.d/sudo:session required pam_limits.so

And my file-max seems to be fine:

$ cat /proc/sys/fs/file-max 
762659

Yet I still have the default 1024 when I check ulimit -a:

$ ulimit -a | grep files
open files                      (-n) 1024

What else can I check?

1
  • Also, just as additional clarification: A ulimit -n 100000 does work as expected (although it doesn't help me because it only persists in the current login session).
    – bantic
    Feb 15, 2011 at 16:31

2 Answers 2

16

I figured out that the system doesn't seem to like the wildcard for the user in limits.conf. Changing that to: root soft nofile 100000 and root hard nofile 100000 worked fine.

2
  • Must be a bug in Ubuntu. I verified that wildcards work in Fedora 14. Feb 14, 2011 at 20:13
  • 16
    Wildcards work, but do not affect the root account. manpages.ubuntu.com/manpages/natty/en/man5/limits.conf.5.html says NOTE: group and wildcard limits are not applied to the root user. To set a limit for the root user, this field must contain the literal username root.
    – Stobor
    Jul 27, 2011 at 5:29
1

Adding another answer as, although bantic solved his problem, we had exactly same setup and symptoms. Ulimit soft and hard for nofile set to 100000 in limits.conf. No over-rides or other ulimit settings for users under /etc or in user's home and yet ulimit was low. Hard ulimit was 4096, soft ulimit was 1024.

Centos 7.

Actually adding an /etc/security/limits.d/20-nofile.conf with soft nofile 100000 and hard nofile 100000 seemed to solve it if you su as the user but not if you ssh in as the user.

Eventually we found UsePAM: no in /etc/ssh/sshd_config Changing to UsePAM: yes and restarting sshd service solved it for us.

1
  • 1
    Seems this is also required on EndeavourOS (Arch) or I guess any distro using systemd's User Manager (check if you have [email protected] running via systemctl status). Then add this: [Manager]<NEWLINE> # Also set in /etc/security/limits.conf<NEWLINE> DefaultLimitNOFILE=16384:65536 to e.g. /etc/systemd/user.conf.d/20-nofile.conf. (Replace <NEWLINE> with actual newlines.)
    – reijerh
    Aug 14, 2023 at 16:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .