Friday, September 13, 2013

Changing ulimit of open files

I wanted to increase the limit on the number of open files, as needed to install a particular new application.

The output of `ulimit -n` was 1024. I had expected that `ulimit -n 2048` command would set the value. Instead, I got the error `bash: ulimit: open files: cannot modify limit: Operation not permitted`.

I tried increasing the ulimit as root: `sudo su -`, and then `ulimit -n 2048`. While this set the limit for root, it did no change for the non-root user.

I also added the following lines to `/etc/security/limits.conf`:
`  soft nofile 2048`
`  soft nofile 4096`

I understand that the above is needed to make the change to ulimit persistent.

Finally, what did work to allow ulimit set as root to be set as non-root user, is appending line `session required` in the file `/etc/pam.d/common-session`.

No comments: