Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I set the following values (-1 will be resolved to unlimited, I suppose) in /etc/security/limits.conf (CentOS 6.2)

root nofile soft -1

root nofile hard -1

and I can't log in with root user now. Similar to the issue described here. Setting the value back would resolve the issue.

Can anyone help to explain this ?


Thanks guys. I memorize my settings incorrectly. Those values should be

root soft nofile -1
root hard nofile -1
share|improve this question
up vote 2 down vote accepted

As @Michael Hampton told you, your syntax is wrong, but anyway i don't think is good idea to set the file limit to unlimited

You can read this post for more information

I downloaded the kernel version linux- and i saw this from kernel/sys.c:

 SYSCALL_DEFINE2(setrlimit, unsigned int, resource, struct rlimit __user *, rlim)
    struct rlimit new_rlim, *old_rlim;
    int retval;

    if (resource >= RLIM_NLIMITS)
            return -EINVAL;
    if (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
            return -EFAULT;
    if (new_rlim.rlim_cur > new_rlim.rlim_max)
            return -EINVAL;
    old_rlim = current->signal->rlim + resource;
    if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
            return -EPERM;
    if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
            return -EPERM;

from man proc

The kernel constant NR_OPEN imposes an upper limit on the value that may be placed in 

from ./fs/file.c:

./fs/file.c:30:int sysctl_nr_open __read_mostly = 1024*1024;
echo $((1024*1024))

why you need more files than nr_open?

i did a test using your limits.conf settings:


 egrep -v "^#|^$" /etc/pam.d/su
 auth       sufficient
 session       required readenv=1
 session       required readenv=1 envfile=/etc/default/locale
 session    optional nopen
 session    required 
 @include common-auth
 @include common-account
 @include common-session

Now i'll to switch to user root using su command:

root@ubuntu:~# strace -e setrlimit su - root
setrlimit(RLIMIT_NOFILE, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = -1 EPERM (Operationnot permitted)
share|improve this answer

You've reversed the second and third fields.

It should read instead:

root soft nofile -1
root hard nofile -1
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.