How to raise open file limit – /etc/security/limits.d vs /etc/security/limits.conf

rhelulimit

Using RHEL7 with systemd

Do you have to use a specific file name convention in /etc/security/limits.d (besides the file ending in .conf)? There is a file in this directory called 20-nproc.conf. So if I wanted to raise the open file limit for USER1 how would I name this .conf file? Does that first number matter? ie. 20 in the .conf file 20-nproc.conf

And should I create this .conf in /etc/security/limits.d directory since /etc/security/limits.conf states:

Also note that configuration files in /etc/security/limits.d directory,
which are read in alphabetical order, override the settings in this
file in case the domain is the same or more specific.
...

Can I create a .conf file called 30-USER1-nofile.conf

which contains

USER1   soft   nofile   6000
USER1   hard   nofile   6000

Best Answer

The conf files in the directory are ascibetically sorted, and each sourced in order.

The numbering is a convention to ensure that all sorting methods agree, and to make inserting new rules easy when it comes to placement.

Do not, do not, edit the limits.conf file, as this is now error-attracting as it is just a bad policy in general (the reasons for which weren't as obvious back then).