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 ~]#
Read up on and try the
pwconv
,pwunconv
andpwck
commands to get your passwd and shadow files in sync again. Then try to use youruserdel
.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.