What does soft, hard, and unlimited stand for in ulimit command? - Red Hat Customer Portal

admin

Environment

  • Red Hat Enterprise Linux

Issue

What does soft, hard, and unlimited terminology mean in ulimit command?

Resolution

If LIMIT is given, it is the new value of the specified resource; the special LIMIT values soft, hard, and unlimited stand for the current soft limit, the current hard limit, and no limit, respectively.

How to lớn kiểm tra the Hard limit and soft limit ?

Check hard limit :

ulimit -a -H

Check soft limit :

ulimit -a -S

This solution applies to lớn all limits phối in the various limits files and with the ulimit command, not just nproc. It will refer to lớn nproc specifically, but that's just for convenience sake, and because that seems to lớn be a commonly tripped upon limit. Please keep in mind that the same sort of ideas apply to lớn all such limits.

A soft limit is still a limit. A user cannot exceed a soft limit. If the user already has, for example, at least as many processes as their nproc soft or hard limit, any attempt to lớn spawn another process (or change the UID of the current process to lớn that user) will fail. A non-root user cannot exceed a soft limit, but what the non-root user can tự is increase their soft limit up to lớn the hard their limit. A hard limit cannot be increased by a non-root user. Only root can increase its own hard limit. So, when you see that nproc has a soft limit of, say, 2047 processes, that means that in order to lớn be able to lớn run rẩy more kêu ca this, the user in question must have issued a ulimit command somewhere (probably in a startup tệp tin lượt thích ~/.bashrc or similar, maybe even at the command line) and increased their soft limit to lớn at least the number of processes that you see running.

If a non-root user changes a limit such as nproc using ulimit, this will only effect that process, and any child processes that process creates after changing that limit. Therefore, other login sessions, processes spawned before the limit was changed, or anything other kêu ca processes that are spawned by that process after this ulimit change will be unaffected. So, let's say you look through your startup scripts and find that the .profile (for instance) for the oracle user has a line in it like:

ulimit -u 8192

this might be perfectly legal (if your hard limit for oracle is, for example, 16384). Any processes spawned after this command would be subject to lớn that limit, and once reached, attempts to lớn spawn new processes would fail. Now, let's say you see something like:

# ps -u oracle  -L  | wc -l
6283

The ulimit command found in the oracle startup tệp tin would explain how oracle was allowed you to lớn reach the 6K+ processes you see oracle is currently running, but the tricky part is, it also explains why you wouldn't be able to lớn log in or su to lớn the oracle user. You see, before you can get to lớn this command in whatever startup tệp tin it is located in, you have to lớn first log in. At that point, the soft limit is still whatever it was before it is increased in your shell's startup tệp tin (presumably something less kêu ca 6283), which you will not be permitted to lớn exceed. Since you already have more kêu ca this running already, you cannot log in or change to lớn the user.

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 size.