9

When I try deleting my user (from a root shell) it says userdel: cannot remove entry 'itaig' from /etc/passwd The user isn't even displayed on /etc/passwd.

[root@ab2c1 ~]# su - itaig
su: warning: cannot change directory to /home/itaig: No such file or directory
-bash-4.1$ exit
logout
[root@ab2c1 ~]# mkdir /home/itaig
[root@ab2c1 ~]# chown itaig.itaig /home/itaig/
[root@ab2c1 ~]# grep itaig /etc/passwd
[root@ab2c1 ~]# grep itaig /etc/shadow
[root@ab2c1 ~]# userdel -rf itaig
userdel: cannot remove entry 'itaig' from /etc/passwd
[root@ab2c1 ~]#

I have the exact same problem in other servers as well but i can't find a common ground between them:

[root@amad ~]# userdel itaig
userdel: cannot remove entry 'itaig' from /etc/passwd
[root@amad ~]# useradd itaig
useradd: user 'itaig' already exists
[root@amad ~]# 

How come my user is not displayed in /etc/passwd but still exists on the system? I've checked /etc/nsswitch.conf and found no problem there... What can be done in order to fix this issue?

Edit: The output of strace userdel itaig can be found here: http://pastebin.com/FFkcQ3fj

And the output of strace useradd itaig: http://pastebin.com/twRQ7ps0

Second Edit: It seems that if I manually add my user to /etc/shadow and /etc/group I am then able to delete the user using the command userdel itaig , but even then I'm unable to re-create the user as I get an error that the user already exists. Any help would be appreciated!

[root@ab2c1 ~]# userdel itaig
[root@ab2c1 ~]# useradd itaig
useradd: user 'itaig' already exists
[root@ab2c1 ~]# userdel itaig
userdel: cannot remove entry 'itaig' from /etc/passwd
[root@ab2c1 ~]# grep itaig /etc/passwd
[root@ab2c1 ~]# grep itaig /etc/group
[root@ab2c1 ~]# grep itaig /etc/shadow
[root@ab2c1 ~]# id itaig
uid=509(itaig) gid=510(itaig) groups=510(itaig)
[root@ab2c1 ~]# 

Contents of /etc/nsswitch.conf:

passwd:     files   nis
shadow:     files   nis
group:      files   nis
#hosts:     db files nisplus nis dns
hosts:      files nis dns
bootparams: nisplus [NOTFOUND=return] files
ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files
netgroup:   nisplus
publickey:  nisplus
automount:  files nisplus
aliases:    files nisplus

I wonder where the information of the id command comes from:

[root@ab2c1 ~]# grep itaig /etc/passwd
[root@ab2c1 ~]# grep itaig /etc/shadow
[root@ab2c1 ~]# grep itaig /etc/group
[root@ab2c1 ~]# id itaig
uid=509(itaig) gid=510(itaig) groups=510(itaig)
[root@ab2c1 ~]#
15
  • What do getent passwd itaig and getent shadow itaig say? Jul 16, 2013 at 13:33
  • Do you have LDAP authentication configured on this machine? Or some other form of remote directory authentication?
    – John
    Jul 16, 2013 at 13:40
  • Etan: the getent password shows me a line like the ones in /etc/passwd and the getent shadow give me a fresh prompt line without and output
    – Itai Ganot
    Jul 16, 2013 at 14:28
  • John: No, only linux security
    – Itai Ganot
    Jul 16, 2013 at 14:28
  • you could try to run strace userdel itaig
    – ALex_hha
    Jul 16, 2013 at 14:57

1 Answer 1

-1

Read up on and try the pwconv, pwunconv and pwck commands to get your passwd and shadow files in sync again. Then try to use your userdel.

Also, is there a reason that you are leaving nis and nisplus defined in your /etc/nsswitch.conf file? I have seen unnecessary naming services cause lag in various functionality due to the fact that they are performing lookups to services that aren't implemented in your environment. I would also clear all of those out to see if you see any improvement in your userdel issue.

5
  • 4
    It seems like I wasn't able to delete the user because it was added on the NIS server... Thanks.
    – Itai Ganot
    Aug 1, 2013 at 18:48
  • 1
    I had a similar issue where the user existed on a SSS server which appears to relate to LDAP. Temporarily removing sss from /etc/nsswitch.conf was the solution for me. Nov 17, 2014 at 1:21
  • 7
    'Read up on' isn't an answer.
    – Stephan
    Jan 8, 2016 at 0:14
  • 1
    Just teaching a person to fish. Mar 24, 2016 at 20:27
  • The purpose of stackoverflow/serverfault isn't to teach people how to fish, it's to provide useful answers to questions. Aug 3, 2021 at 4:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .