Removing multiple accounts with UID 0

We are running a RHEL 6 server, and for reasons I won't delve into at the moment a few additional accounts were created with UID 0 giving them root access.

I want to get rid of them, but trying to delete the user by username doesn't work as the OS goes by UID and says they are logged in. If I try to log them out all processes owned by root are killed off (ya, learned that the hard way).

I theorize that using usermod might let me change the UID - but I don't know if that will also affect the root account.

Should I just create a dummy account, then edit /etc/passwd to set the UID and group for each account to the UID / group of the dummy account, then remove them all?

What do you suggest that will not result in locking up the server?

Who is Participating?
You might also just delete the relevant lines /etc/passwd and /etc/shadow. You don't need to do anything else.
Just edit /etc/password and change the "wrong" UIDs to numbers of your choice.

You can delete these accounts then by means of "userdel", if you wish.
RKFcomputersAuthor Commented:
Thank you both!

Sadly I'm not getting alerts from Experts Exchange, so I didn't see these until now.

I've copied the passwd to a backup, just in case, then deleted all the users but one. That one I'll probably change to a new user number.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.