Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

chown .htaccess files in public_html?

Discussion in 'General Discussion' started by Robert Wiseman, Jun 10, 2018.

  1. Robert Wiseman

    Robert Wiseman Registered

    Joined:
    Jun 10, 2018
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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?
     
  2. Jcats

    Jcats Well-Known Member

    Joined:
    May 25, 2011
    Messages:
    703
    Likes Received:
    114
    Trophy Points:
    168
    Location:
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    cPanelLauren likes this.
  3. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    1,445
    Likes Received:
    98
    Trophy Points:
    103
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @Robert Wiseman

    Because there's no automatic way to do this the solution suggested by @Jcats would work for what you're wanting to do.


    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice