I plan to run a Java app using nohup ... &. The limit must apply to commands like this.

  • But this caused an error in my java program – bruce dou Mar 8 '10 at 8:53

Most systems use PAM, and have the pam_limits module set limits based on /etc/security/limits.conf. The per-user limit for open files is called nofile. You can set it for every user or for a particular user or group, and you can set a limit that the user can override (soft limit) and another that only root can override (hard limit). The documentation and the limits.conf man page have the details. For example, to raise the limit to 50000 for everyone, put this line in /etc/limits.conf (the setting takes effect when you log in):

* - nofile 50000
| improve this answer | |
  • within limits.conf do * hard nofile 50000 and/or * soft nofile 50000. I don't know the technical difference between hard and soft and have always done both. – ron Mar 2 at 18:39
  • within SLES 11.4 using tcsh for example, one can do limit descriptors 50000 to change the value within the given terminal window/session. – ron Mar 2 at 18:41
  • @ron -` in the second column sets both the soft and the hard limit. You only need to set them separately if you want different values. A soft limit can be changed at any time by running the ulimit command (called limit in csh). An unprivileged user can never go higher than the hard limit. – Gilles 'SO- stop being evil' Mar 3 at 22:22
  • if i only set the hard, does the soft value remain the default? if I only set soft and not hard, does hard remain default value or inherently equal soft value? Can I set soft > hard? The soft is the real value that is in effect? sorry for the questions. – ron Mar 4 at 14:14
  • @ron The soft limit is automatically capped at the hard limit. If you only set the hard limit, then this sets the soft limit to max(default_soft_limit, actual_hard_limit). – Gilles 'SO- stop being evil' Mar 4 at 17:22

you can add fs.file-max = <your number> into /etc/sysctl.conf. Then reboot.

| improve this answer | |
  • cat /proc/sys/fs/file-max is 169203,but ulimit -n is 1024 – bruce dou Mar 8 '10 at 8:51
  • No need to reboot. Just run sysctl fs.file-max=123456. (/etc/sysctl.conf is read at boot time by a script that calls sysctl on the contents.) – Gilles 'SO- stop being evil' Apr 5 '11 at 21:06
ulimit -n

can modify per process settings and


or the sysctl variable called fs.file-max can be used to read and set the system-wide value

| improve this answer | |
  • cat /proc/sys/fs/file-max is 169203,but ulimit -n is 1024 – bruce dou Mar 8 '10 at 8:47

You can use ulimit for this:


Although you should make sure that opening so many file handles is absolutely necessary before resorting to such adjustments. Increasing the maximum file handles just because you have forgotten to do an inputstream.close() in a loop is only going to delay the underlying problem.

| improve this answer | |
  • 1
    I want to connect to lots of clients – bruce dou Mar 8 '10 at 8:52

Use ulimit(Bash command - man bash or find similar for your shell) per program instance. Do not use global system limits if you don't know what are you doing - possible DoS.

| improve this answer | |
  • In SLES 11.4 I have set nofile in limits.conf to be 100000 successfully. I can attest that setting too large a value prevented subsequent log in with SSH and I had to boot from dvd to correct that value in limits.conf to recover the system. – ron Mar 2 at 18:45
vi ~/.bashrc

And add a line at the end of file

ulimit -n 169203
| improve this answer | |

Your Answer

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