Script to change server wide ownership
Have you mistakenly changed ownership for all the users recursively? Or fired the ownership command in /home folder on cPanel server? Don't worry, you can rectify it by resorting below easy script.
# You can opt desired name for your script
$ vi myscript.sh
# Input following contents to created file
#!/bin/bash
cd /var/cpanel/users
for user in *
do
chown -Rv $user.$mail /home/$user/etc
chown -v $user.$nobody /home/$user/public_html
chown -Rv $user.$user /home/$user
done
# Change permissions of the file for script execution
chmod 755 myscript.sh
Or
chmod +x myscript.sh
# Run the script and it will start correcting ownership of all the users on your cPanel server. It may take some time depending upon the number of users.
$ ./myscript.sh
Or
$ sh myscript.sh
Or
$ bash myscript.sh
Enjoy !!!
|