I recently had an issue with incorrect ownership of all files under /home/user/ due to mismatched UIDs after a cPanel server restore. The following script took care of this in no time.
echo -e "Checking ownership of /home/user \n"
for i in `ls /var/cpanel/users/`
do
if [ "$i" != "root" ]; then
chown -R $i:$i /home/$i
chown $i:nobody /home/$i/public_html /home/$i/.htpasswds
chown $i:mail /home/$i/etc /home/$i/etc/*/shadow /home/$i/etc/*/passwd
echo $i
fi
done