LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-20-2014, 02:50 AM   #1
harunaadoga
LQ Newbie
 
Registered: Sep 2014
Location: Hatfield, United Kingdom
Distribution: Centos
Posts: 24

Rep: Reputation: Disabled
userdel command without -r option


Hello everyone, I am a newbie with the linux OS and have been playing around with adding and removing users, after adding a new user, I tried deleting the user using the userdel command without the -r option, using the ls command still shows the user on my PC and if i try to delete the user again, it says such user does not exist even when i use the -r option. What should I do to get rid of the user ? Iam using the Centos Distro. any help will be appreciated
 
Old 09-20-2014, 04:09 AM   #2
Philip Lacroix
Member
 
Registered: Jun 2012
Distribution: Slackware
Posts: 441

Rep: Reputation: 574Reputation: 574Reputation: 574Reputation: 574Reputation: 574Reputation: 574
Hello and welcome to LQ! The "-r" option removes the user's home directory along with its mail (see below the lines from the man page). If you have already issued the "userdel" command, the user is not there anymore, so it doesn't have any effect now: what you see with the "ls" command is not the user itself, but its home directory ("ls" lists files, not existing users). If you want to remove the mentioned home directory you now have to do that manually (as root) with the "rm -r" (remove recursively) command. Pay attention to the fact that after you have removed it, the directory and its content are gone, and might be recovered (no guarantee) only by using specific tools.

Code:
$ man userdel
Code:
-r, --remove
    Files in the user's home directory will be removed along with the
    home directory itself and the user's mail spool. Files located in
    other file systems will have to be searched for and deleted
    manually.

Last edited by Philip Lacroix; 09-20-2014 at 04:11 AM.
 
Old 09-20-2014, 10:42 AM   #3
harunaadoga
LQ Newbie
 
Registered: Sep 2014
Location: Hatfield, United Kingdom
Distribution: Centos
Posts: 24

Original Poster
Rep: Reputation: Disabled
Re: userdel command without -r option

Thanks @Philip Lacroix I tried using the rm -r command to remove the user home directory but the directory still exists, I am probably getting something wrong, the recursive remove does not seem to be doing the job for me.
 
Old 09-20-2014, 10:54 AM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Can you post the exact command you're entering and any error messages you might have received? Note that you will generally need to have root priveliges to delete a directory not owned by you. Also, it good to remember that rm is permanent. There's no trash bin like on some other OSes from which you can recover the files. So make sure there's really nothing in that directory that you (or someone else) might want before you delete it. Tools do exist for data recovery, but it's best to not need to use them in the first place!
 
Old 09-21-2014, 05:41 AM   #5
Philip Lacroix
Member
 
Registered: Jun 2012
Distribution: Slackware
Posts: 441

Rep: Reputation: 574Reputation: 574Reputation: 574Reputation: 574Reputation: 574Reputation: 574
Quote:
Originally Posted by harunaadoga
I tried using the rm -r command to remove the user home directory but the directory still exists, I am probably getting something wrong, the recursive remove does not seem to be doing the job for me.
Please follow btmiller's above suggestions, so that we can help you effectively. If you still have doubts about commands, files, folders and permissions on Linux systems, I recommend you a guide which is worth reading:

Introduction to Linux - A Hands on Guide, by Machtelt Garrels
 
Old 09-21-2014, 06:06 AM   #6
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,491

Rep: Reputation: Disabled
Quote:
Originally Posted by harunaadoga View Post
Thanks @Philip Lacroix I tried using the rm -r command to remove the user home directory but the directory still exists, I am probably getting something wrong, the recursive remove does not seem to be doing the job for me.
Needs the command to be issued as the 'root' user; either use sudo or su, to gain 'root', (if using su, don't forget to use 'exit', so that you don't do anything bad accidentally ).
 
  


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
[SOLVED] run ps|grep command by script/command line ... ERROR: Unsupported option (BSD syntax) masuch Programming 4 05-23-2012 04:13 AM
problem with useradd/userdel command on RHEL5 smsahmed Linux - General 9 07-04-2010 02:11 AM
Userdel command , Need explaination srihariv Linux - General 4 03-07-2008 02:57 AM
bash: userdel: command not found dwdrumrboy Linux - Newbie 9 04-16-2005 11:47 AM
userdel command... should I run it? The_Nerd Linux - Software 2 09-12-2004 08:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:50 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