Follow the steps below to impose a limit on the number of open files for a certain user.
Using vi open /etc/security/limits.conf. The syntax in limits.conf is given below.
<domain> <type> <item> <value>
In the above code,
<domain> - may be username/groupname/wildcard('*') <type> - may be hard/soft/'-'
- hard
To enforce strict resource constraints. The superuser sets these constraints, which the Kernel enforces. The user’s demand for system resources cannot exceed certain limits.
- soft
Used to enforce soft resource constraints. These are the restrictions that the user can adjust within the range allowed by any pre-existing hard limits. For normal system usage, the values supplied with this token can be thought of as default values.
- item> – may be nofile/nproc, etc.
- value> – to be set value.
Set the entries as.
soft nofile hard nofile
For example:
user1 soft nofile 4096 user1 hard nofile 65536
Save the file with :wq
Login to the server as a user to check.