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 04-10-2015, 11:02 AM   #1
mhsahkir
LQ Newbie
 
Registered: Dec 2014
Location: U.S.A ,NEWYORK
Posts: 24

Rep: Reputation: Disabled
How to remove a user?


When i tried to remove a user as well its home directory using this command "userdel -r username" but still its exists on home directory why?
Attached Thumbnails
Click image for larger version

Name:	shakirtttt.jpg
Views:	67
Size:	41.7 KB
ID:	18065   Click image for larger version

Name:	shakirtttt ahmed.jpg
Views:	57
Size:	23.0 KB
ID:	18066  
 
Old 04-10-2015, 11:49 AM   #2
vincix
Member
 
Registered: Feb 2011
Distribution: Centos 6.7, 7
Posts: 676

Rep: Reputation: 69
Because of the fact that you've already deleted the user before, without deleting his home directory, now there's no association between that user and that home directory, because the user simply doesn't exist. Therefore, the home directory has become a normal folder. If you don't associate it with another user, for instance by creating a new user and pointing to that home directory (useradd user -d /home/student), then your only choice is to simply delete that directory with rm -rf /home/student.

On the other hand, if you haven't deleted any users and you think that the user associated with /home/student might still exist in your system, you can check /etc/passwd:

Code:
cat /etc/passwd | grep student
If no output is displayed, then it means that no user is associated with that home directory.

Last edited by vincix; 04-10-2015 at 11:51 AM.
 
3 members found this post helpful.
Old 04-10-2015, 04:10 PM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,696

Rep: Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261
I would also suggest looking at the users home directory (ls -ld /home/name), just in case the directory has been given to a different user. If only the UID shows in the ownership, then there is no user id association.

This is because just looking at the /etc/passwd file may not be sufficient - the user may be in LDAP/NIS or other naming system - which would still be a valid user, just not listed in the /etc/passwd file.
 
Old 04-10-2015, 04:28 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
If this is a local user and you want to delete user along with his / her home directory then you should user the command:
Code:
userdel -r <username>
If you don't like to -r switch then you can create an alias for userdel to be run as userdel -r. Remember once you created the alias it will userdel will work as userdel -r so if sometime you don't want to delete the user's home directory and just the user, either you remove the alias or move home directory somewhere else before running that command.

Since it is showing uid instead of the username I would say the directory went orphaned (not sure if it is the right term) and system allotted UID of the user which use to own then directory.

I doubt that it was an LDAP user but still to confirm you can run:
Code:
getent passwd | grep <uid_or_username>
 
Old 04-10-2015, 06:09 PM   #5
mhsahkir
LQ Newbie
 
Registered: Dec 2014
Location: U.S.A ,NEWYORK
Posts: 24

Original Poster
Rep: Reputation: Disabled
How to remove a user?

I got a new problem,when i logged in as a root it should be # sign but its gonna showing me regular user sign. You guys have any idea whats wrong with my system?
Attached Thumbnails
Click image for larger version

Name:	Screenshot.png
Views:	20
Size:	61.3 KB
ID:	18081  
 
Old 04-10-2015, 06:16 PM   #6
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Once you do su - root or su - then type the output of the following commands:

1.
Code:
whoami
2.
Code:
cat /etc/passwd | grep -i root
3.
Code:
echo $PATH
Edit: Also paste the output of:
Code:
echo $SHELL

Last edited by T3RM1NVT0R; 04-10-2015 at 06:17 PM.
 
Old 04-15-2015, 02:53 AM   #7
mhsahkir
LQ Newbie
 
Registered: Dec 2014
Location: U.S.A ,NEWYORK
Posts: 24

Original Poster
Rep: Reputation: Disabled
Ok,Guys i got my problem solution when i tried to remove the user from home directory its said "userdel: user 'username' does not exist
" when i used useradd command its said
"useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Creating mailbox file: File exists" Finally i used this command "sudo rm -rf /home/username" and its deleted.
 
Old 04-15-2015, 11:58 PM   #8
vincix
Member
 
Registered: Feb 2011
Distribution: Centos 6.7, 7
Posts: 676

Rep: Reputation: 69
Quote:
Originally Posted by mhsahkir View Post
Ok,Guys i got my problem solution when i tried to remove the user from home directory its said "userdel: user 'username' does not exist
" when i used useradd command its said
"useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Creating mailbox file: File exists" Finally i used this command "sudo rm -rf /home/username" and its deleted.
We're all happy you haven't read any of our posts. You're welcome.
 
1 members found this post helpful.
  


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] How can any user remove a file created by other user with all permissions(777)? omegazafer Linux - Desktop 5 06-28-2013 02:31 AM
Can't Remove User carlosinfl Red Hat 11 01-30-2010 11:27 AM
Remove user reggae999 Linux - Software 2 10-07-2009 04:25 PM
How to remove the user? ukrainet Linux - Newbie 1 12-15-2004 05:40 AM
Remove a user ToothlessRebel Linux - General 8 10-22-2004 03:36 PM


All times are GMT -5. The time now is 12:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration