Centos – After using userdel -r to remove a user, user still appears on login screen (CentOS 7)

centosuser-management

I used userdel -r [username] on CentOS 7 to delete a user, but the user is still appearing on the GUI login screen. Also, useradd now refuses to add the same username again, reporting that the user already exists. Another userdel command for that user reports that it cannot remove the user from /etc/passwd. However, the user doesn't appear in either passwd or shadow files.

If I go into the GUI settings screen for users, the user appears there. Using the "-" button to remove the user does nothing though. There's no visible error.

Any ideas? I deleted a couple of users at the same time, and the others all seem to have gone as expected.

Best Answer

Turned out to be confusion when connected to an LDAP server for authentication. The LDAP server had a user with the same name as the one on the local computer I'd been trying to remove. Hence them still showing up on the Gnome login screen.

First time running "userdel -rf fred" works fine, and removes the local user, but if you then try to add fred again, you start getting errors due to fred existing in LDAP.