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


*                hard    nofile          1048576

Here I get:

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

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)

  • 2
    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, 2017 at 15:17
  • Hi, I am having a very similar problem. I think it would be very helpful to provide more details on what these different systems are.
    – Time4Tea
    Apr 25, 2020 at 17:56

1 Answer 1


Check that /etc/ssh/sshd_config contains:


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

session    required   pam_limits.so

In the comment below @venimus states the 1M limit is hardcoded:

The kernel 2.6.x source states ./fs/file.c:30:int sysctl_nr_open __read_mostly = 1024*1024; which is 1048676

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

  • 6
    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, 2017 at 11:03
  • 2
    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, 2018 at 22:36
  • 2
    What's ssh got to do with it?
    – Linas
    Dec 21, 2018 at 23:59
  • 1
    I agree with @Linas . Sorry, I think the link between the answer and the question is unclear.
    – Time4Tea
    Apr 25, 2020 at 17:59
  • 1
    if you are interactions over ssh pam limits need to set the pam module for ssh to include the limits file otherwise activity over ssh will not work
    – Arturski
    Apr 8, 2022 at 15:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .