What are the true user's ulimits ?
Environment
- Red Hat Enterprise Linux 5.4
Issue
- In a different scenarios SSH or direct logins, it turns that I have different limits set with a
ulimit -n(no of files) yet, not the one from the '/etc/security/limits.conf' file in either cases.
Resolution
-
The Red Hat Enterprise Linux system uses two types of values to define the limits: soft and hard. The difference is that the 'soft' limit can be adjusted up to the 'hard' limit while 'hard' limit can only be lessened and it is the maximum resource limit a user may have. So what limit is in use?
-
Whenever a user runs a
ulimit -ncommand, it will be presented with the "soft" limit. Hence, if the '/etc/security/limits.conf' file has a hard value set, it will not be presented by default. To illustrate the situation, the following commands might be used: -
For soft limits:
[root@host]# ulimit -n -S -
For hard limits:
[root@host]# ulimit -n -H -
The 'soft' limit can be adjusted upon the 'hard' limit with the below where N is less or equal of the 'hard' limit.
[root@host]# ulimit -n N -
One important pitfall is that by omitting the '-S' (soft) or '-H' (hard) options it will change both the 'soft' and 'hard' limits at once, which means it can't be "reset" without a re-login.
-
If the 'soft' option is specified, then the default 'hard' limit value should be kept in mind (for example, 1024 for a number of open files) and increased explicitly as well if more is needed, or to limit the 'soft' limit to a maximum of 'hard' one. Yet another possibility is to specify the dash '-' instead of 'soft' or 'hard' for both soft and hard limits all together.
-
On the other hand, the same ulimit limits might have different values when connected over a Secure Shell, SSH. To see why, please look at this article for explanations: This content is not included.Why are ulimit values not being set properly upon SSH (Secure Shell) login
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.