samhagin

Registered
Sep 28, 2010
4
0
51
I accidentally run chown for a user in the wrong directory. All the system files and cPanel user files now have wrong ownership. Is there a way to run a chown command that will reset all ownerships to the default?

Any help will be appreciated. Running PHP is SuPHP gives 403 and 500 Internal Server Errors. Currently running PHP as CGI to eliminate the error. I however want to use SuPHP as this is more secure.

Thanks
 

samhagin

Registered
Sep 28, 2010
4
0
51
This command fixed it. It changed the ownership for each directory to the cPanel user for it.

for i in `ls /var/cpanel/users`; do chown -R $i:$i /home/$i/public_html/*; done

Additionally if your permissions are off, this two commands will change perms for all folders to 755 and 644 for all files

find /home/*/public_html/* -type f -exec chmod 644 {} \;
find /home/*/public_html/* -type d -exec chmod 755 {} \;
 

forum17

Active Member
Mar 30, 2007
29
0
151
I accidentally run chown for a user in the wrong directory. All the system files and cPanel user files now have wrong ownership. Is there a way to run a chown command that will reset all ownerships to the default?

Any help will be appreciated. Running PHP is SuPHP gives 403 and 500 Internal Server Errors. Currently running PHP as CGI to eliminate the error. I however want to use SuPHP as this is more secure.

Thanks
Hello,

etc folders need user.mail ownership and public_html needs group owner as nobody. So use the following commands to fix the issue.

for i in `ls /var/cpanel/users`; do chown $i:$i /home/$i -R; done
for i in `ls /var/cpanel/users`; do chown $i:nobody /home/$i/public_html; done
for i in `ls /var/cpanel/users`; do chown $i:mail /home/$i/etc -R; done