2

I want to increase the hard limit of maxfiles using ulimit -Hn for the current bash shell. The problem is I can not do it without using sudo. But, when I do sudo ulimit -Hn unlimited, it does not effect the current shell's limits, instead it changes the limit for a child shell which is invoked for sudo.

Is there a way to achieve it for the current shell from with we are issuing the ulimit command? I am using Mac OS x 10.6.x.

Thanks in advance.

6
  • And you can't change this before starting the shell without privileges? May 18 '12 at 9:44
  • what do you mean?Sorry, I did not get your question.
    – Aarkan
    May 18 '12 at 9:52
  • I mean, you could sudo to root, change the ulimit, su to normal user, execute script. May 18 '12 at 9:55
  • Something like this sudo sh -c "ulimit -c 10 ; sudo -u $USER sh -c 'whoami ; ulimit -a'" May 18 '12 at 9:57
  • No, I dont have the root's password.
    – Aarkan
    May 18 '12 at 9:58
0

You can use:

sudo bash -c "ulimit -Hn unlimited; su $USER"

This will change the ulimit for the spawned shell and then change the user to yours. This will not raise the ulimits on your current shell, but rather create another with higher privileges and attach it to your terminal.

Still, you might not be able to increase the hard limit of opened files, even as root.. Process headers are only so big.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy