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

Multi tool use
Multi tool use

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













80















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?










share|improve this question



















  • 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















80















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?










share|improve this question



















  • 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













80












80








80


22






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?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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












  • 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







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










2 Answers
2






active

oldest

votes


















73














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.






share|improve this answer


















  • 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 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


















0














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.






share|improve this answer






















    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
    );



    );













    draft saved

    draft discarded


















    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









    73














    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.






    share|improve this answer


















    • 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 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















    73














    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.






    share|improve this answer


















    • 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 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













    73












    73








    73







    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.






    share|improve this answer













    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.







    share|improve this answer












    share|improve this answer



    share|improve this answer










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












    • 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 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







    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













    0














    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.






    share|improve this answer



























      0














      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.






      share|improve this answer

























        0












        0








        0







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        Ankit ShubhamAnkit Shubham

        1112




        1112



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            NpnS9 Yl xtutHRqx32omyrFftHv
            Dv1KUGJHF7azr95oB,6 m8C,Rddw om 8 wvrSYE YmRUQWbc5sp4,QS

            Popular posts from this blog

            getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

            NetworkManager fails with “Could not find source connection”Trouble connecting to VPN using network-manager, while command line worksHow can I be notified about state changes to a VPN adapterBacktrack 5 R3 - Refuses to connect to VPNFeed all traffic through OpenVPN for a specific network namespace onlyRun daemon on startup in Debian once openvpn connection establishedpfsense tcp connection between openvpn and lan is brokenInternet connection problem with web browsers onlyWhy does NetworkManager explicitly support tun/tap devices?Browser issues with VPNTwo IP addresses assigned to the same network card - OpenVPN issues?Cannot connect to WiFi with nmcli, although secrets are provided

            Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.