Unable to set nofiles soft limit

First, I created the file /etc/systemd/system.conf.d/50-nfiles.conf, and I set “DefaultLimitNOFILE=8192”.

Second, I created the file /etc/security/limits.conf, and I added the line “* soft nofile 8192”

Third, I coped /usr/share/pam.d/common-session to /etc/pam.d, and I added the line “session required pam_limits.so”.

After rebooting, “ulimit -Hn” gives me 8192 (as expected), but “ulimit -Sn” gives me 1024 (unexpected).

I then comment out the line “session optional pam_systemd.so” in /etc/pam.d/common-session, reboot, and now “ulimit -Sn” gives me 8192 (as expected). But now, a lot of other stuff (like networking) doesn’t work properly.

So, how can I set the default soft limit for nofiles? (I am using Clear Linux version 32550).

Maybe try:

session required pam_limits.so conf=/etc/security/limits.conf

You can also try adding debug here as well - check man pam_limits for more info.