Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

Attempting to add a (non-existant) user to my CentOS system is returning useradd: user example exists. I can successfully manually add the user to /etc/passwd and /etc/shadow, but that workaround is A Bad Thing. The user exists in LDAP, but PAM isn't using LDAP for authentication. Adding other users works fine. I'm stumped.


[root ~]# userdel example
userdel: error deleting password entry
userdel: error deleting shadow password entry
[root ~]# useradd example
useradd: user example exists
[root ~]# su example
bash-3.2$ whoami
bash-3.2$ groups example
example : Users
bash-3.2$ cd
bash: cd: /home/example: No such file or directory
share|improve this question
Have a look at this:… – Khaled Jan 16 '12 at 13:46
What did you get if you try su example? – Khaled Jan 16 '12 at 13:48
@Khaled It drops me into a standard bash shell. pwd shows location as /root. whoami shows as the user, groups example shows that they're a member of the Users group – Tom Jan 16 '12 at 13:50
useradd aliased? – Tim Jan 16 '12 at 14:32
[root@ ~]# which useradd /usr/sbin/useradd, not aliased. – Tom Jan 16 '12 at 14:33
up vote 7 down vote accepted

If you include LDAP in the /etc/nsswitch.conf (for example passwd: files ldap or passwd:compat passwd_compat:ldap, etc.) it is enough for getent passwd and thus for useradd to see LDAP entries.

Both utilities have nothing to do with PAM, and happily recognize LDAP entries even if PAM knows nothing about LDAP.

By the way, if you have nscd running, remember to restart it after you change nsswitch.conf.

share|improve this answer
Goodness, my understanding of linux auth is clearly lacking. I didn't know that was a thing. That was it, thanks! – Tom Jan 16 '12 at 15:03

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.