-   Red Hat (
-   -   Deleting User in Red Hat Linux (

ashali19 09-13-2012 07:02 AM

Deleting User in Red Hat Linux
Dear all,

I am sorry and i am not sure if this is the right category to post this qns.

Basically i have added a few users using the command:

e.g useradd alice

I accidentely deleted the user using:

e.g userdel alice and not using userdel -r alice.

when i use ls , i realise that the users are visible but the systems says users do not exist.

May i know how to get rid of the users?

pan64 09-13-2012 07:13 AM

I think user is now locked, unable to log in, but the files are still there, you need to remove home dir and other files also (owned by alice)

ashali19 09-13-2012 07:25 AM

delete home dir
Hi there,

r u saying that i should use rmdir /home and remove all of its content?

pan64 09-13-2012 08:17 AM

no, rmdir /home/alice would be better. do not remove /home! be care about removing anything, it can be dangerous!

onebuck 09-13-2012 08:53 AM

Moderator Response
Moved: This thread is more suitable in <Red Hat> and has been moved accordingly to help your thread/question get the exposure it deserves.

ashali19 09-13-2012 09:21 AM

delete home dir
Hi there,

When i do rmdir /home/alice

it says that directory no empty.

How do i delete the username that is visible but apparently not existing?

YankeePride13 09-13-2012 09:36 AM


rm -r /home/alice

ashali19 09-13-2012 09:40 AM

delete home dir
hi there,

The rm -r /home/alice worked.. but the problem is that i have to type y for all the files that are deleted.

Is it possible to force delete all the users without selecting y or yes all the time?

YankeePride13 09-13-2012 09:56 AM

Sure, try:


rm -rf /home/alice

ashali19 09-13-2012 10:00 AM

that worked perfectly fine. a huge thank you :P

by the way when i add the same user again it says
creating mailbox file:File exist

this comment normally wont be prompted when a new user is added.

any reason why and how to avoid this?

thanks in advance

YankeePride13 09-13-2012 10:06 AM

Try this:

rm -rf /var/spool/mail/alice
In the future when you delete a user, make sure to include the -r option with the userdel command as this will remove the home directory and user's mail spool (that is, if you want that to happen).

ashali19 09-13-2012 10:08 AM

thank you soo much for the prompt reply.. i am studying for the RHCE exam ... :)

YankeePride13 09-13-2012 10:09 AM

No prob, please mark the thread as solved and feel free to give me rep points :)

ashali19 09-13-2012 10:11 AM

by the way how do i delete all the spool mails for all the users at once?

is there a command?

thank you

YankeePride13 09-13-2012 10:26 AM

I've never had to do that before, so I'm not really sure if there's a command to do that. Depending on the number of users in your system, I'd write a script to purge their mail spools one by one.

Just be sure to be careful when you do this (if you do this in a real world situation) because without proper backups it's 100% assured that someone will need one of the e-mails you delete somewhere down the line.

All times are GMT -5. The time now is 10:09 PM.