Robert Wiseman

Registered
Jun 10, 2018
1
0
1
England
cPanel Access Level
Root Administrator
Hi,

We are trying to upgrade our hosted sites to php7.2 but for some reason around 50% of .htaccess files in public_html have the user set to root:root.

Is there a way to update all .htaccess within all user accounts to their correct user account please?
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
806
156
168
New Jersey
cPanel Access Level
DataCenter Provider
This will recursively search each account for .htaccess and change the ownership accordingly:

Code:
for user in $(whmapi1 listaccts|grep user | awk '{print$2}') ; do find /home/"$user"/public_html/ -type f -name .htaccess -exec chown -v "$user": {} \; ; done
Might take a while depending on how many accounts

If you strictly only want to change ownership of /home/user/public_html/.htaccess then do

Code:
for user in $(whmapi1 listaccts|grep user | awk '{print$2}') ; do chown -v "$user": /home/"$user"/public_html/.htaccess ; done
 
  • Like
Reactions: cPanelLauren