Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

When I do a ulimit -n I got 256, I assume it means I can open 256 files at the sametime. Does it means I can open 256 files with one single session? or all sessions?

For example, I logined to my server with username "abc" (via putty/ssh), and open 200 files, with the session still running, I logined to the same server again with the same username "abc" (via putty/ssh), I can open only another 56 files? or I can open another 256 files?

Lastly, does this limit also restrict number of http connections? e.g. with the above example, I have opened 200 files, and then I use "wget" or "curl" to make http connections.

Thanks

share|improve this question
1  
I don't remember if ulimit sets per-process or a per-user limits. The limit, however, is on file descriptors which include local files, network connections, and more. Downloading a file with wget would be at least two file descriptors: one for the network connection and one for the local file it's saving to –  DerfK May 31 '12 at 2:44

2 Answers 2

up vote 5 down vote accepted

ulimit is a bash builtin, so it applies only to the shell, and particularly any processes created by the current shell. Hence if you change it for any reason you will have to do so in a persistent way.

You might want to checkout the /etc/security/limits.conf file for setting session limits on a per-user basis. (which appears to be the CentOS preferred method)

you can see open files using the lsof -P | grep $somepid command

share|improve this answer

Linux system limits number of open file descriptors per-process.

256 seems enough for most websites, if you use Apache with preforking MPM.

To increase limit you need to add a line to /etc/security/limits.conf to allow processes of some user or group to increase default value. After that PAM will set this to maximum the moment you log in. But that is not enough for Apache, since it doesn't "login".

You will also need to increase this values before starting Apache. In CentOS you can edit your /etc/init.d/apache2 script and put ulimit -n XXXXXX into beggining of start() function.

You can check limit for running process in file /proc/<PID>/limits, list of open file descriptors is in /proc/<PID>/fd/

share|improve this answer

Your Answer

 
discard

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.