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.

Can someone write me a quick chowing script?

Discussion in 'General Discussion' started by noimad1, Oct 17, 2006.

  1. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    I've been working all night with no sleep restoring a server that was hacked. however, all of my file owners are all messed up.

    Could someone write me a quick script (if possible) that would search through the /home directory and chown -R all of the files for each users root home directory to that users account?
     
  2. jugo

    jugo Active Member

    Joined:
    Nov 23, 2005
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    Try this

    Try this bro...

    Code:
    #!/bin/sh
    
    ls -A /var/cpanel/users/ > users
    for account in `cat users`
    do
    echo "***************************"
    echo "** chowning $account     **"
    echo "***************************"
    echo ""
    
    chown -R $account:nobody /home/$account
    
    echo "***************************"
    echo "*** $account Completed ***"
    echo "***************************"
    echo ""
    done
    
    
     
  3. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    That won't quite work. Only the /home/username/public_html directory is username:nobody ownership. Everything in that directory is supposed to be username:username.
     
  4. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    Thank you. I was able to use your script and modify it a bit and run it again for the public_html directories....

    Thank you!
     
Loading...

Share This Page