How to Delete unnecessary Entry in /etc/shadow

Question: How to remove all the unnecessary user entries in /etc/shadow file.

1. Create a backup copy of /etc/shadow file.

# cp -p /etc/shadow /etc/shadow.backup

2. Ensure the user is not existing anymore in /etc/password file.

# cat /etc/passwd | grep [userid]

3. Edit the /etc/shadow file, look for the line and remove the unnecessary user entry.

# vi /etc/shadow

4. Ensure the user is not existing anymore in /etc/shadow file.

# cat /etc/shadow | grep [userid]
Note: The steps above should only be used when all other efforts have failed to remove the user.
Related Post