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.

Help please! Mistake by do the Chown at the root !

Discussion in 'General Discussion' started by calvinphanctt, May 15, 2007.

  1. calvinphanctt

    calvinphanctt Active Member

    Joined:
    Mar 27, 2007
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    Hello,

    I need a big help from you! I made a big mistake by instead of doing the command "chown" in a directory, but I did it at the root, and now all the domains on my dedicated server get corrupted and not accessible. The e-mails accounts on those domains from this server stop running too.

    My problem: I tried to copy all the contents of an account called "user1" of domain "user1.com" into a second account "user2" of domain "user2.com" with command:

    Step 1: cd /home/user1/public_html
    Step 2: cp -r * /home/user2/public_html

    My web hosting technician asked me to do the "chown" command to set permission for the files I copied from user1 to user2

    Step 3: chown -R user2.user2 *

    Here is the problem came: She did not mention me to do it from inside the account of "user2". And at that time, there is something wrong with my SSH and I had to log in again, and I WAS in the root and I did the above command

    chown -R user2.user2 *

    So, now all the domains on this dedicated server went crazy. I got the error message like "Forbidden
    You don't have permission to access / on this server.

    Additionally, a 403 Forbidden error was encountered
    while trying to use an ErrorDocument to handle the
    request.=20"

    Now, what should I do to correct this problem ? How do I set the "chown" permission for each users again ? Please help me! I'm so worry now.

    Regards,
    Calvin
     
    #1 calvinphanctt, May 15, 2007
    Last edited: May 15, 2007
  2. ramprage

    ramprage Well-Known Member

    Joined:
    Jul 21, 2002
    Messages:
    667
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Canada
    How many accounts are there on the server?
     
  3. calvinphanctt

    calvinphanctt Active Member

    Joined:
    Mar 27, 2007
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    There are 20 accounts on the server

    Hello,

    There are 20 accounts on the server.

    Before I give up, I hope there is a way I can recover back the mistake.

    I'm not sure if I buy another server and transfer all the accounts to the new server will that help clear this problem ? (But this not what I wanted ...take time a lot!)

    What is the best way to transfer the accounts to the new server (My data is very big ... total about 120 GB) ? Could someone show me the step by step ? I've done the "Copy accounts" from the WHM but really take time too.

    Please help me! Thanks a lot!

    Regards,
    Calvin
     
    #3 calvinphanctt, May 15, 2007
    Last edited: May 15, 2007
  4. erik@delphi

    erik@delphi Well-Known Member

    Joined:
    Jul 9, 2005
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Belgium
    hi,

    can i be honest ? allright this is a permissions issue finding where the problem resides might take allot of time and angry clients yelling at you.This is one of the reasons

    NEVER BE ROOT UNLESS IT IS ABOSOLUTELY NECESARRY

    my personal opinon would ne reload your server os and then restore a backup
     
  5. yapluka

    yapluka Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    301
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    France
    cPanel Access Level:
    Root Administrator
    If I get it well, all accounts are now owned by root ? I think this little script shoud fix your issue :

    Code:
    #!/bin/bash
    cd /var/cpanel/users
    for user in *
    do
    chown -R $user.$user /home/$user/
    chown $user.nobody /home/$user/public_html
    chown $user.mail /home/$user/etc
    done
    
    Good luck :)
     
  6. calvinphanctt

    calvinphanctt Active Member

    Joined:
    Mar 27, 2007
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    How do I run that script ?

    Hi yapluka,

    How do I run that script?

    By the way, I've done that at the root, but I am not sure if all account was own by root. How to check ?

    By the way, on this server there are 2 hard drives separtely. First hard drive is install at /home (there are some accounts on this) and second hard drive install at /home2/ (some accounts on this)

    Will that script still do the job? I have to run that command for every user? Do I do this in root ?

    Thanks for your help!

    Regards,
    Calvin
     
    #6 calvinphanctt, May 15, 2007
    Last edited: May 15, 2007
  7. yapluka

    yapluka Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    301
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    France
    cPanel Access Level:
    Root Administrator
    Hi Calvin,

    To run the script :
    Code:
    pico /root/chownacct.sh
    Then paste the following :

    Code:
    #!/bin/bash
    cd /var/cpanel/users
    for user in *
    do
    if [ -e /home/$user ]; then
    chown -R $user.$user /home/$user/
    chown $user.nobody /home/$user/public_html
    chown $user.mail /home/$user/etc
    
    else
    chown -R $user.$user /home2/$user/
    chown $user.nobody /home2/$user/public_html
    chown $user.mail /home2/$user/etc
    fi
    done
    Save it (Ctrl + X)

    Then type :
    Code:
    sh /root/chownacct.sh
    Feel free to contact me on msn or YIM (see my profile) if you need any further help. :)
     
  8. calvinphanctt

    calvinphanctt Active Member

    Joined:
    Mar 27, 2007
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    I did but it seems to do nothing ?

    Hi Yapluka,

    I did but it seems to do nothing? Is there another way?

    Regards,
    Calvin
     
  9. yapluka

    yapluka Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    301
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    France
    cPanel Access Level:
    Root Administrator
    Well, it's not easy to help you without seeing how it shows up on the server... did you run the script as root ?
    Also you may need to check the permissions if all your domains are returning an error 403.
    For example :
    /home/username/ >> 711
    /home/username/public_html/ >> 750
     
  10. nithintou

    nithintou Member

    Joined:
    Dec 22, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    he missed making the script executable part :

    chmod +x /root/chownacct.sh
     
  11. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    836
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    if I read this post right, I think there's problems with a lot more than just the files in the user accounts. Maybe you should get someone who knows what they're doing to have a look.
     
  12. nithintou

    nithintou Member

    Joined:
    Dec 22, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    i think verdon is right. That script just chowns the home directories to the user whereas theres loads of services which require permissions to files in other folders for functioning nicely.
    your best bet would be to backup all of /home to somewhere else,reinstall operating system and move everything back.
     
Loading...

Share This Page