0 votes
1 view
in AWS by (12.3k points)

After SSH'ing into an EC2 instance running the Amazon Linux AMI, I tried:

ulimit -n 20000

...and got the following error:

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

However, the shell allows me to decrease this number, for the current session only.

Is there anyway to increase the ulimit on an EC2 instance (permanently)?


1 Answer

+2 votes
by (18.6k points)
selected by
Best answer

If you change the values through ulimit command, it will only apply the changes to the current shell session. For permanent changes, you will have to edit limits.conf file and set your hard and soft limits. You can find your limits.conf file in /etc/security/limits.conf

here's how you can do it:

# <domain> <type> <item>  <value>

    *       soft  nofile  20000

    *       hard  nofile  20000

Save this file.

Logout and login again, run the ulimit -n command to test the configuration.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !