LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 09-13-2012, 07:02 AM   #1
ashali19
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Rep: Reputation: Disabled
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?
 
Old 09-13-2012, 07:13 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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)
 
Old 09-13-2012, 07:25 AM   #3
ashali19
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: Disabled
delete home dir

Hi there,

r u saying that i should use rmdir /home and remove all of its content?
 
Old 09-13-2012, 08:17 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
no, rmdir /home/alice would be better. do not remove /home! be care about removing anything, it can be dangerous!
 
Old 09-13-2012, 08:53 AM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
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.
 
Old 09-13-2012, 09:21 AM   #6
ashali19
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: Disabled
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?
 
Old 09-13-2012, 09:36 AM   #7
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 262

Rep: Reputation: 55
try:
Code:
rm -r /home/alice
 
Old 09-13-2012, 09:40 AM   #8
ashali19
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: Disabled
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?
 
Old 09-13-2012, 09:56 AM   #9
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 262

Rep: Reputation: 55
Sure, try:

Code:
rm -rf /home/alice
 
1 members found this post helpful.
Old 09-13-2012, 10:00 AM   #10
ashali19
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: Disabled
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
 
Old 09-13-2012, 10:06 AM   #11
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 262

Rep: Reputation: 55
Try this:
Code:
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).
 
Old 09-13-2012, 10:08 AM   #12
ashali19
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: Disabled
thank you soo much for the prompt reply.. i am studying for the RHCE exam ...
 
Old 09-13-2012, 10:09 AM   #13
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 262

Rep: Reputation: 55
No prob, please mark the thread as solved and feel free to give me rep points
 
1 members found this post helpful.
Old 09-13-2012, 10:11 AM   #14
ashali19
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: Disabled
by the way how do i delete all the spool mails for all the users at once?

is there a command?

thank you
 
Old 09-13-2012, 10:26 AM   #15
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 262

Rep: Reputation: 55
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
adding/deleting Red Hat Satellite Base Channels iffarrukh Linux - Software 1 05-28-2012 11:16 PM
[SOLVED] i want to install xp without deleting red hat linux 5 hunnykhan3 Linux - Newbie 16 09-02-2009 12:28 PM
Deleting games from red hat 8 mustang05 Linux - Software 3 06-17-2006 05:25 PM
red hat deleting a file 0007 Linux - Software 1 01-29-2005 08:35 AM
Deleting Java 1.4.2 from Red Hat 8 mustang05 Linux - Software 1 05-20-2004 10:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 01:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration