The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Chown Nightmare

Discussion in 'General Discussion' started by samhagin, Oct 29, 2010.

  1. samhagin

    samhagin Registered

    Joined:
    Sep 28, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,478
    Likes Received:
    202
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    What directory were you in or was affected?
     
  3. samhagin

    samhagin Registered

    Joined:
    Sep 28, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I was in the /home directory
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,478
    Likes Received:
    202
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
  5. samhagin

    samhagin Registered

    Joined:
    Sep 28, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    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 {} \;
     
  6. forum17

    forum17 Active Member

    Joined:
    Mar 30, 2007
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    0
    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
     
Loading...

Share This Page