ulimit: difference between hard and soft limitsLimits on the number of file descriptorsulimit & rlimit in Linux, are they the same thing?ulimit vs. limit on FreeBSD 8.3Limits on the number of file descriptorsWhat are the effects of increasing hard and soft limits for ldap userProcess specific ulimit still low after changes to soft and hard ulimitsHow “Max open files” soft and hard limit are set for specific process?Configuring ulimit of `max open files` for daemonized nginx master processSoft limit vs hard limitSetting OS X/MacOS/BSD maxfileulimit value not changing for a processIncreasing open files limit for all processes: Do I need to set Soft/Hard limits?Why ulimit -n modifies hard limit
Why not increase contact surface when reentering the atmosphere?
Balance Issues for a Custom Sorcerer Variant
For a non-Jew, is there a punishment for not observing the 7 Noahide Laws?
How to run a prison with the smallest amount of guards?
Hostile work environment after whistle-blowing on coworker and our boss. What do I do?
How do I find the solutions of the following equation?
How does it work when somebody invests in my business?
Lay out the Carpet
How can a function with a hole (removable discontinuity) equal a function with no hole?
Avoiding estate tax by giving multiple gifts
Sort a list by elements of another list
How to safely derail a train during transit?
Integer addition + constant, is it a group?
Unreliable Magic - Is it worth it?
Escape a backup date in a file name
Implement the Thanos sorting algorithm
How to be diplomatic in refusing to write code that breaches the privacy of our users
Pole-zeros of a real-valued causal FIR system
Two monoidal structures and copowering
Fine Tuning of the Universe
How does the UK government determine the size of a mandate?
Is `x >> pure y` equivalent to `liftM (const y) x`
Gears on left are inverse to gears on right?
What Brexit proposals are on the table in the indicative votes on the 27th of March 2019?
ulimit: difference between hard and soft limits
Limits on the number of file descriptorsulimit & rlimit in Linux, are they the same thing?ulimit vs. limit on FreeBSD 8.3Limits on the number of file descriptorsWhat are the effects of increasing hard and soft limits for ldap userProcess specific ulimit still low after changes to soft and hard ulimitsHow “Max open files” soft and hard limit are set for specific process?Configuring ulimit of `max open files` for daemonized nginx master processSoft limit vs hard limitSetting OS X/MacOS/BSD maxfileulimit value not changing for a processIncreasing open files limit for all processes: Do I need to set Soft/Hard limits?Why ulimit -n modifies hard limit
What is the difference between hard and soft limits in ulimit?
For number of open files, I have a soft limit of 1024 and a hard limit of 10240.
It is possible to run programs opening more than 1024 files. What is the soft limit for?
open-files ulimit
add a comment |
What is the difference between hard and soft limits in ulimit?
For number of open files, I have a soft limit of 1024 and a hard limit of 10240.
It is possible to run programs opening more than 1024 files. What is the soft limit for?
open-files ulimit
4
Are you talking aboutulimit -n
? Try running a shell with a very low value (bash -c 'ulimit -n 4; exec 3>a; exec 4>b; exec 5>c'
). What's the output?
– Gilles
Jan 20 '12 at 17:23
add a comment |
What is the difference between hard and soft limits in ulimit?
For number of open files, I have a soft limit of 1024 and a hard limit of 10240.
It is possible to run programs opening more than 1024 files. What is the soft limit for?
open-files ulimit
What is the difference between hard and soft limits in ulimit?
For number of open files, I have a soft limit of 1024 and a hard limit of 10240.
It is possible to run programs opening more than 1024 files. What is the soft limit for?
open-files ulimit
open-files ulimit
edited Jan 20 '12 at 17:08
user13742
asked Jan 20 '12 at 16:59
daniel kullmanndaniel kullmann
5,28272842
5,28272842
4
Are you talking aboutulimit -n
? Try running a shell with a very low value (bash -c 'ulimit -n 4; exec 3>a; exec 4>b; exec 5>c'
). What's the output?
– Gilles
Jan 20 '12 at 17:23
add a comment |
4
Are you talking aboutulimit -n
? Try running a shell with a very low value (bash -c 'ulimit -n 4; exec 3>a; exec 4>b; exec 5>c'
). What's the output?
– Gilles
Jan 20 '12 at 17:23
4
4
Are you talking about
ulimit -n
? Try running a shell with a very low value (bash -c 'ulimit -n 4; exec 3>a; exec 4>b; exec 5>c'
). What's the output?– Gilles
Jan 20 '12 at 17:23
Are you talking about
ulimit -n
? Try running a shell with a very low value (bash -c 'ulimit -n 4; exec 3>a; exec 4>b; exec 5>c'
). What's the output?– Gilles
Jan 20 '12 at 17:23
add a comment |
2 Answers
2
active
oldest
votes
A hard limit can only be raised by root (any process can lower it). So it is useful for security: a non-root process cannot overstep a hard limit. But it's inconvenient in that a non-root process can't have a lower limit than its children.
A soft limit can be changed by the process at any time. So it's convenient as long as processes cooperate, but no good for security.
A typical use case for soft limits is to disable core dumps (ulimit -Sc 0
) while keeping the option of enabling them for a specific process you're debugging ((ulimit -Sc unlimited; myprocess)
).
The ulimit
shell command is a wrapper around the setrlimit
system call, so that's where you'll find the definitive documentation.
Note that some systems may not implement all limits. Specifically, some systems don't support per-process limits on file descriptors (Linux does); if yours doesn't, the shell command may be a no-op.
5
+1 for the soft limits use case. Resident set size limit (ulimit -m
,RLIMIT_RSS
) is an example of a limit that isn't effective on Linux anymore. Virtual memory limit (ulimit -v
,RLIMIT_AS
) works, though.
– Adam Zalcman
Jan 20 '12 at 17:53
@Gilles, do you mean without restarting the process, when we change the soft limit, it can be effect immediately?
– Ryan
Jun 29 '13 at 2:52
1
@Ryan Yes, a program can change its own soft limit at any time by callingsetrlimit
(to the extent permitted by the hard limit unless running as root of course). Most programs don't have a command that lets the user do that, but you can try attaching to the program with a debugger and making it issue asetrlimit
call, or under Linux you can callprlimit
(for which I don't know of any shell utility).
– Gilles
Jun 29 '13 at 8:27
There is now aprlimit
shell utility too.
– telcoM
yesterday
add a comment |
The hard limit is for the security purpose. For a non-root user, he can only decrease the hard limit from the currently set hard limit; he cannot increase it. Increasing the hard limit can be done only by root user (or maybe with sudo privilege, not sure about that). What a non-root user can do is choose a limit (called soft limit) which can be in the range [0, hard limit] for its processes. Its the soft limit which is seen and taken in consideration by the processes.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f29577%2fulimit-difference-between-hard-and-soft-limits%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
A hard limit can only be raised by root (any process can lower it). So it is useful for security: a non-root process cannot overstep a hard limit. But it's inconvenient in that a non-root process can't have a lower limit than its children.
A soft limit can be changed by the process at any time. So it's convenient as long as processes cooperate, but no good for security.
A typical use case for soft limits is to disable core dumps (ulimit -Sc 0
) while keeping the option of enabling them for a specific process you're debugging ((ulimit -Sc unlimited; myprocess)
).
The ulimit
shell command is a wrapper around the setrlimit
system call, so that's where you'll find the definitive documentation.
Note that some systems may not implement all limits. Specifically, some systems don't support per-process limits on file descriptors (Linux does); if yours doesn't, the shell command may be a no-op.
5
+1 for the soft limits use case. Resident set size limit (ulimit -m
,RLIMIT_RSS
) is an example of a limit that isn't effective on Linux anymore. Virtual memory limit (ulimit -v
,RLIMIT_AS
) works, though.
– Adam Zalcman
Jan 20 '12 at 17:53
@Gilles, do you mean without restarting the process, when we change the soft limit, it can be effect immediately?
– Ryan
Jun 29 '13 at 2:52
1
@Ryan Yes, a program can change its own soft limit at any time by callingsetrlimit
(to the extent permitted by the hard limit unless running as root of course). Most programs don't have a command that lets the user do that, but you can try attaching to the program with a debugger and making it issue asetrlimit
call, or under Linux you can callprlimit
(for which I don't know of any shell utility).
– Gilles
Jun 29 '13 at 8:27
There is now aprlimit
shell utility too.
– telcoM
yesterday
add a comment |
A hard limit can only be raised by root (any process can lower it). So it is useful for security: a non-root process cannot overstep a hard limit. But it's inconvenient in that a non-root process can't have a lower limit than its children.
A soft limit can be changed by the process at any time. So it's convenient as long as processes cooperate, but no good for security.
A typical use case for soft limits is to disable core dumps (ulimit -Sc 0
) while keeping the option of enabling them for a specific process you're debugging ((ulimit -Sc unlimited; myprocess)
).
The ulimit
shell command is a wrapper around the setrlimit
system call, so that's where you'll find the definitive documentation.
Note that some systems may not implement all limits. Specifically, some systems don't support per-process limits on file descriptors (Linux does); if yours doesn't, the shell command may be a no-op.
5
+1 for the soft limits use case. Resident set size limit (ulimit -m
,RLIMIT_RSS
) is an example of a limit that isn't effective on Linux anymore. Virtual memory limit (ulimit -v
,RLIMIT_AS
) works, though.
– Adam Zalcman
Jan 20 '12 at 17:53
@Gilles, do you mean without restarting the process, when we change the soft limit, it can be effect immediately?
– Ryan
Jun 29 '13 at 2:52
1
@Ryan Yes, a program can change its own soft limit at any time by callingsetrlimit
(to the extent permitted by the hard limit unless running as root of course). Most programs don't have a command that lets the user do that, but you can try attaching to the program with a debugger and making it issue asetrlimit
call, or under Linux you can callprlimit
(for which I don't know of any shell utility).
– Gilles
Jun 29 '13 at 8:27
There is now aprlimit
shell utility too.
– telcoM
yesterday
add a comment |
A hard limit can only be raised by root (any process can lower it). So it is useful for security: a non-root process cannot overstep a hard limit. But it's inconvenient in that a non-root process can't have a lower limit than its children.
A soft limit can be changed by the process at any time. So it's convenient as long as processes cooperate, but no good for security.
A typical use case for soft limits is to disable core dumps (ulimit -Sc 0
) while keeping the option of enabling them for a specific process you're debugging ((ulimit -Sc unlimited; myprocess)
).
The ulimit
shell command is a wrapper around the setrlimit
system call, so that's where you'll find the definitive documentation.
Note that some systems may not implement all limits. Specifically, some systems don't support per-process limits on file descriptors (Linux does); if yours doesn't, the shell command may be a no-op.
A hard limit can only be raised by root (any process can lower it). So it is useful for security: a non-root process cannot overstep a hard limit. But it's inconvenient in that a non-root process can't have a lower limit than its children.
A soft limit can be changed by the process at any time. So it's convenient as long as processes cooperate, but no good for security.
A typical use case for soft limits is to disable core dumps (ulimit -Sc 0
) while keeping the option of enabling them for a specific process you're debugging ((ulimit -Sc unlimited; myprocess)
).
The ulimit
shell command is a wrapper around the setrlimit
system call, so that's where you'll find the definitive documentation.
Note that some systems may not implement all limits. Specifically, some systems don't support per-process limits on file descriptors (Linux does); if yours doesn't, the shell command may be a no-op.
answered Jan 20 '12 at 17:17


GillesGilles
544k12811041621
544k12811041621
5
+1 for the soft limits use case. Resident set size limit (ulimit -m
,RLIMIT_RSS
) is an example of a limit that isn't effective on Linux anymore. Virtual memory limit (ulimit -v
,RLIMIT_AS
) works, though.
– Adam Zalcman
Jan 20 '12 at 17:53
@Gilles, do you mean without restarting the process, when we change the soft limit, it can be effect immediately?
– Ryan
Jun 29 '13 at 2:52
1
@Ryan Yes, a program can change its own soft limit at any time by callingsetrlimit
(to the extent permitted by the hard limit unless running as root of course). Most programs don't have a command that lets the user do that, but you can try attaching to the program with a debugger and making it issue asetrlimit
call, or under Linux you can callprlimit
(for which I don't know of any shell utility).
– Gilles
Jun 29 '13 at 8:27
There is now aprlimit
shell utility too.
– telcoM
yesterday
add a comment |
5
+1 for the soft limits use case. Resident set size limit (ulimit -m
,RLIMIT_RSS
) is an example of a limit that isn't effective on Linux anymore. Virtual memory limit (ulimit -v
,RLIMIT_AS
) works, though.
– Adam Zalcman
Jan 20 '12 at 17:53
@Gilles, do you mean without restarting the process, when we change the soft limit, it can be effect immediately?
– Ryan
Jun 29 '13 at 2:52
1
@Ryan Yes, a program can change its own soft limit at any time by callingsetrlimit
(to the extent permitted by the hard limit unless running as root of course). Most programs don't have a command that lets the user do that, but you can try attaching to the program with a debugger and making it issue asetrlimit
call, or under Linux you can callprlimit
(for which I don't know of any shell utility).
– Gilles
Jun 29 '13 at 8:27
There is now aprlimit
shell utility too.
– telcoM
yesterday
5
5
+1 for the soft limits use case. Resident set size limit (
ulimit -m
, RLIMIT_RSS
) is an example of a limit that isn't effective on Linux anymore. Virtual memory limit (ulimit -v
, RLIMIT_AS
) works, though.– Adam Zalcman
Jan 20 '12 at 17:53
+1 for the soft limits use case. Resident set size limit (
ulimit -m
, RLIMIT_RSS
) is an example of a limit that isn't effective on Linux anymore. Virtual memory limit (ulimit -v
, RLIMIT_AS
) works, though.– Adam Zalcman
Jan 20 '12 at 17:53
@Gilles, do you mean without restarting the process, when we change the soft limit, it can be effect immediately?
– Ryan
Jun 29 '13 at 2:52
@Gilles, do you mean without restarting the process, when we change the soft limit, it can be effect immediately?
– Ryan
Jun 29 '13 at 2:52
1
1
@Ryan Yes, a program can change its own soft limit at any time by calling
setrlimit
(to the extent permitted by the hard limit unless running as root of course). Most programs don't have a command that lets the user do that, but you can try attaching to the program with a debugger and making it issue a setrlimit
call, or under Linux you can call prlimit
(for which I don't know of any shell utility).– Gilles
Jun 29 '13 at 8:27
@Ryan Yes, a program can change its own soft limit at any time by calling
setrlimit
(to the extent permitted by the hard limit unless running as root of course). Most programs don't have a command that lets the user do that, but you can try attaching to the program with a debugger and making it issue a setrlimit
call, or under Linux you can call prlimit
(for which I don't know of any shell utility).– Gilles
Jun 29 '13 at 8:27
There is now a
prlimit
shell utility too.– telcoM
yesterday
There is now a
prlimit
shell utility too.– telcoM
yesterday
add a comment |
The hard limit is for the security purpose. For a non-root user, he can only decrease the hard limit from the currently set hard limit; he cannot increase it. Increasing the hard limit can be done only by root user (or maybe with sudo privilege, not sure about that). What a non-root user can do is choose a limit (called soft limit) which can be in the range [0, hard limit] for its processes. Its the soft limit which is seen and taken in consideration by the processes.
add a comment |
The hard limit is for the security purpose. For a non-root user, he can only decrease the hard limit from the currently set hard limit; he cannot increase it. Increasing the hard limit can be done only by root user (or maybe with sudo privilege, not sure about that). What a non-root user can do is choose a limit (called soft limit) which can be in the range [0, hard limit] for its processes. Its the soft limit which is seen and taken in consideration by the processes.
add a comment |
The hard limit is for the security purpose. For a non-root user, he can only decrease the hard limit from the currently set hard limit; he cannot increase it. Increasing the hard limit can be done only by root user (or maybe with sudo privilege, not sure about that). What a non-root user can do is choose a limit (called soft limit) which can be in the range [0, hard limit] for its processes. Its the soft limit which is seen and taken in consideration by the processes.
The hard limit is for the security purpose. For a non-root user, he can only decrease the hard limit from the currently set hard limit; he cannot increase it. Increasing the hard limit can be done only by root user (or maybe with sudo privilege, not sure about that). What a non-root user can do is choose a limit (called soft limit) which can be in the range [0, hard limit] for its processes. Its the soft limit which is seen and taken in consideration by the processes.
answered yesterday


Ankit ShubhamAnkit Shubham
1112
1112
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f29577%2fulimit-difference-between-hard-and-soft-limits%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
Are you talking about
ulimit -n
? Try running a shell with a very low value (bash -c 'ulimit -n 4; exec 3>a; exec 4>b; exec 5>c'
). What's the output?– Gilles
Jan 20 '12 at 17:23