LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-06-2010, 10:35 AM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 77
Orphaned Home Directories?


For some reason on my mail server when I ran my 'delete-user.sh' script, it did everything correct except remove their actual /home/$USERNAME folder from the system. The users are deleted from /etc/passwd, /etc/shadow, /etc/group, & /etc/gshadow. Is there some way on my Linux system I can search and remove these useless orphaned home directories that didn't get deleted by my script? I am sure the are some 10-20 directories that are just vacant but I have too many users on the server to figure this out.

Thanks for any help!
 
Old 10-06-2010, 11:31 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Something like
Code:
find /home/* -maxdepth 0 -type d -not -name lost+found -printf '%f\n'|while read USERNAME; do 
 getent passwd $USERNAME >/dev/null 2>&1 || echo "Remove /home/${USERNAME}"
done
?

Last edited by unSpawn; 10-06-2010 at 12:58 PM.
 
1 members found this post helpful.
Old 10-06-2010, 11:40 AM   #3
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Thank you but I am not sure where your code starts / stops. Can you encode using ?
 
Old 10-06-2010, 12:33 PM   #4
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
EDIT
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Root/Home Directory and setting up FTP for home directories? Mankind75 Linux - Newbie 6 07-23-2006 02:37 PM
Sharing directories outside of /home... AudioMechanic Linux - Networking 1 03-16-2005 08:18 PM
browseable home directories kenji1903 Linux - Networking 18 07-30-2004 04:10 AM
Samba and Home Directories dlucas10 Linux - Networking 5 10-28-2003 12:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:24 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
Open Source Consulting | Domain Registration