Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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'm trying to increase the maximum number of open files for the current user

> ulimit -n

I attempt to increase and fail as follows

> ulimit -n 4096
bash: ulimit: open files: cannot modify limit: Operation not permitted

So I do the natural thing and try to run with temp permission, but fail

> sudo ulimit -n 4096
sudo: ulimit: command not found


  1. How to increase ulimit?
  2. Why is this happening?

Using Fedora 14

share|improve this question
Reponse to deleted comment: ulimit 4096 doesn't work. I think -n is correct. As a proof of concept it works if I first sudo su - root (but only changes for root). – paislee Feb 14 '12 at 20:01
en.m.wikipedia.org/wiki/Rundown – paislee Oct 26 '15 at 1:29
up vote 10 down vote accepted

ulimit is a shell built-in, not an external command. It needs to be built in because it acts on the shell process itself, like cd: the limits, like the current directory, are a property of that particular process.

sudo bash -c 'ulimit -n 4096' would work, but it would change the limit for the bash process invoked by sudo only, which would not help you.

There are two values for each limit: the hard limit and the soft limit. Only root can raise the hard limit; anyone can lower the hard limit, and the soft limit can be modified in either direction with the only constraint that it cannot be higher than the hard limit. The soft limit is the actual value that matters.

Therefore you need to arrange that all your processes have a hard limit for open files of at least 4096. You can keep the soft limit at 1024. Before launching that process that requires a lot of files, raise the soft limit. In /etc/security/limits.conf, add the lines

paislee hard nofile 4096
paislee soft nofile 1024

where paislee is the name of the user you want to run your process as. In the shell that launches the process for which you want a higher limit, run

ulimit -Sn unlimited

to raise the soft limit to the hard limit.

share|improve this answer
Alternatives to sudo bash -c are sudo -i which starts a login shell and sudo -s whcih starts a shell. The same limitations apply but this might be useful in other circumstances. – Bram Apr 21 at 12:47

open the file /etc/security/limits.conf and add the line <user> soft nofile <value>. for using ulimit change to root user and try the same.

share|improve this answer
sudo sh -c "ulimit -n 65535 && exec su $LOGNAME"

is a possible workaround to the built-in limitation mentioned by Gilles.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.