Skip to content

Instantly share code, notes, and snippets.

@danmilleruk
Created August 30, 2013 10:05
Show Gist options
  • Save danmilleruk/6388324 to your computer and use it in GitHub Desktop.
Save danmilleruk/6388324 to your computer and use it in GitHub Desktop.
Finds cPanel users that no longer exist on a particular system, but where the home directory is still intact.
#!/bin/bash
# Find removed accounts
# Dan Miller <dm@sub6.com>
cd /home
LS=`ls -1 | grep -v 'aquota.user\|cagefs\|quota.user\|lost+found\|cpbandwidth\|cprestore\|cpeasyapache'`
echo ""
echo "Searching for users with no accounts on `/bin/hostname`"
echo ""
for i in $LS
do
if [ ! -e "/var/cpanel/users/$i" ]; then
SIZE=`du -sh /home/$i | awk '{print $1}'`
echo "- [$SIZE] No userfile match for $i"
echo ""
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment