Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from May 19 '12 at 1:31

This question came from our site for professional and enthusiast programmers.

And you can't change this before starting the shell without privileges? – Mattias Wadman 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. – Mattias Wadman May 18 '12 at 9:55
Something like this sudo sh -c "ulimit -c 10 ; sudo -u $USER sh -c 'whoami ; ulimit -a'" – Mattias Wadman May 18 '12 at 9:57
No, I dont have the root's password. – Aarkan May 18 '12 at 9:58

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.