You are not logged in.

#1 2010-02-02 14:54:21

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Orphaned Home Directories

I realized my script for deleting users was not working properly. For some reason it did delete the user account from the system but did not use the 'userdel -r' command. I think I may have left some home directories in the system that are from old deleted accounts. Is there a command or way I can see what directories under /home are not tied to accounts that are in /etc/passwd?


./

Offline

#2 2010-02-02 15:47:07

grey
Member
From: Europe
Registered: 2007-08-23
Posts: 679

Re: Orphaned Home Directories

If the list isn't too large:

$ sed 's/\:.*$//' /etc/passwd |sort >  a1
$ ls /home/ |sort >  a2
$ diff a1 a2

Good ideas do not need lots of lies told about them in order to gain public acceptance.

Offline

#3 2010-02-02 15:54:55

panuh
Member
From: X :ɯoɹℲ
Registered: 2009-11-24
Posts: 144

Re: Orphaned Home Directories

for file in /home/*
do echo $file: $(cat /etc/passwd|grep $file|wc -l)
done

I know this is a really ugly script but that's because I'm all at the beginning. But I wished to once post a script in the forum so hard big_smile

I don't know how full your /home/ is and how long this will take. But anyway... Maybe it could actually help XD

btw. it will pass a list of all folders. a zero next to abandoned folders.

EDIT: Okay... grey wins in every sense tongue but it was a start.

Last edited by panuh (2010-02-02 16:01:21)

Offline

#4 2010-02-03 10:51:39

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: Orphaned Home Directories

find owns you :-)

find /home -maxdepth 1 -nouser

Regards,

raf

Offline

Board footer

Powered by FluxBB