limits.conf not being read when logging in

July 16, 2014 2k views

I have 2 entries in my limits.conf,

*       hard        nofile      10240
*       soft        nofile      4096

but running ulimit -Sn or ulimit -Hn only displays the default values.

gabriel@server:~$ ulimit -Sn
gabriel@server:~$ ulimit -Hn

It works fine on one server but on another it's as if they're being ignored.
I did have a problem with apt-get autoremove for some old kernels on this one server which I didn't have on the other, I didn't note it down but I'm quite able to reboot.

1 comment
5 Answers

Add the following line to both /etc/pam.d/common-session and /etc/pam.d/common-session-noninteractive

session required

After that, log out and log in again.

  • @info tried that, no luck still

  • If you also need it to work for the root user, you need to add two more lines to limits.conf:

    root hard nofile 10240
    root soft nofile 4096

    I've just tested this on a new droplet with ubuntu 14.04 and it works as long as is loaded.

    If this still doesn't solve your problem then try to reboot the server.

It's not for root just normal users, it works on other droplets fine, it used to work on this droplet but for some reason doesn't anymore. Have rebooted a few times :)

  • Either is not being loaded (corrupt file / version mismatch) or some script is manually changing the limits back to the default values. I've never seen a script do this so the problem is most likely caused by

    I have no idea how you can resolve this issue as I've never had it happen before. As you don't experience it with your other droplets, my only solution would be to create a new droplet.

Any idea how to tell if is corrupted?

  • Take a look at /var/log/auth.log and see if any errors/warnings are being logged when you log in.

@info nope, no errors being reported

Have another answer? Share your knowledge.