9

I tested this on different GNU/Linux installations:

perl -e 'while(1){open($a{$b++}, "<" ,"/dev/null") or die $b;print " $b"}'

System A and D

The first limit I hit is 1024. It is easily raised by putting this into /etc/security/limits.conf:

*                hard    nofile          1048576

and then run:

ulimit -n 1048576
echo 99999999 | sudo tee /proc/sys/fs/file-max

Now the test goes to 1048576.

However, it seems I cannot raise it above 1048576. If I put 1048577 in limits.conf it is simply ignored.

What is causing that?

System B

On system B I cannot even get to 1048576:

echo 99999999 | sudo tee /proc/sys/fs/file-max

/etc/security/limits.conf:

*                hard    nofile          1048576

Here I get:

$ ulimit -n 65537
bash: ulimit: open files: cannot modify limit: Operation not permitted
$ ulimit -n 65536
#OK

Where did that limit come from?

System C

This system also has the 1048576 limit in limits.conf and 99999999 in /proc/sys/fs/file-max.

But here the limit is 4096:

$ ulimit -n 4097
-bash: ulimit: open files: cannot modify limit: Operation not permitted
$ ulimit -n 4096
# OK

How do I raise that to (at least) 1048576?

(Note to self: Don't do: echo 18446744073709551616 | sudo tee /proc/sys/fs/file-max)

  • I have exactly the same issue, the limit seems to be 1048576. If I go over I get the following error: bash: ulimit: open files: cannot modify limit: Operation not permitted – Abbadon Oct 25 '17 at 15:17
3

Check that /etc/ssh/sshd_config contains:

UsePAM=yes

and that /etc/pam.d/sshd contains:

session    required   pam_limits.so

Still no answer to why 1048576 is max.

The 1048576 seems to be per process. So by having multiple processes this limit can be overcome.

  • 2
    If this was really the solution to your own problem, I think it'd be good to draw more of a connection between the problem and the above solution. – Jeff Schaller Apr 17 '17 at 11:03
  • Re: 1048576 (= 2^10 * 2^10 = 1024^2, for reference). There may be some relevant information in this answer here: stackoverflow.com/a/1213069/2320823 – saladi Oct 9 '18 at 22:36
  • What's ssh got to do with it? – Linas Dec 21 '18 at 23:59

Your Answer

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

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