LinuxQuestions.org
Visit Jeremy's Blog.
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, 03: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, 05:09 AM   #2
Philip Lacroix
Member
 
Registered: Jun 2012
Distribution: Slackware{,-current}, OpenBSD
Posts: 373

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
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 05:11 AM.
 
Old 09-20-2014, 11: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, 11:54 AM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
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, 06:41 AM   #5
Philip Lacroix
Member
 
Registered: Jun 2012
Distribution: Slackware{,-current}, OpenBSD
Posts: 373

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
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, 07:06 AM   #6
fatmac
Senior Member
 
Registered: Sep 2011
Location: Surrey/Hants Border, UK
Distribution: BSD & Linux - As long as they are Lightweight
Posts: 1,704

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 05:13 AM
problem with useradd/userdel command on RHEL5 smsahmed Linux - General 9 07-04-2010 03:11 AM
Userdel command , Need explaination srihariv Linux - General 4 03-07-2008 03:57 AM
bash: userdel: command not found dwdrumrboy Linux - Newbie 9 04-16-2005 12:47 PM
userdel command... should I run it? The_Nerd Linux - Software 2 09-12-2004 09:31 PM


All times are GMT -5. The time now is 11:25 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration