Can someone write me a quick chowing script?

noimad1

Well-Known Member
Mar 27, 2003
629
0
166
I've been working all night with no sleep restoring a server that was hacked. however, all of my file owners are all messed up.

Could someone write me a quick script (if possible) that would search through the /home directory and chown -R all of the files for each users root home directory to that users account?
 

jugo

Active Member
Nov 23, 2005
44
0
156
Try this

Try this bro...

Code:
#!/bin/sh

ls -A /var/cpanel/users/ > users
for account in `cat users`
do
echo "***************************"
echo "** chowning $account     **"
echo "***************************"
echo ""

chown -R $account:nobody /home/$account

echo "***************************"
echo "*** $account Completed ***"
echo "***************************"
echo ""
done
 

noimad1

Well-Known Member
Mar 27, 2003
629
0
166
jugo said:
Try this bro...

Code:
#!/bin/sh

ls -A /var/cpanel/users/ > users
for account in `cat users`
do
echo "***************************"
echo "** chowning $account     **"
echo "***************************"
echo ""

chown -R $account:nobody /home/$account

echo "***************************"
echo "*** $account Completed ***"
echo "***************************"
echo ""
done
Thank you. I was able to use your script and modify it a bit and run it again for the public_html directories....

Thank you!