"could not open session" shows when nofile is set to unlimited in /etc/security/limits.conf

Solution Verified - Updated -

Issue

  • When the nofile is set to unlimited in /etc/security/limits.conf file the user cannot login:

    user  soft nofile 1024
    user  hard nofile unlimited
    
    # su - user
    could not open session
    
  • The messages in /var/log/secure:

    login: pam_unix(remote:session): session opened for user root by (uid=0)
    login: Permission denied
    login: pam_limits(remote:session): Could not set limit for 'nofile': Operation not permitted
    
    su: pam_limits(su:session): Could not set limit for 'nofile': Operation not permitted
    su: pam_unix(su:session): session opened for user root by test(uid=501)
    
    pam: gdm-password: pam_limits(gdm-password:session): Could not set limit for 'nofile': Operation not 
    permitted
    pam: gdm-password: pam_unix(gdm-password:session): session opened for user root by (uid=0)
    

Environment

  • Red Hat Enterprise Linux 4
  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content