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.

fixing file ownerships

Discussion in 'General Discussion' started by verdon, Feb 12, 2007.

  1. 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 had a bunch of files in various /home/user/public_html dirs that were owned by root and not the user, would something like the following work to fix them up? Please keep in mind while you are guffawing that I know next to nothing about perl...

    Code:
    #!/usr/bin/perl
    print "Starting Scan...\n";
    while(@USERS=getpwent()){
        if (-d "$USERS[7]/public_html") {
            system("find", "$USERS[7]/public_html", "-user root", "-exec chown $USERS[2]:$USERS[3]") or die "cannot find in this dir.\n";
        }
    }
    print "Scan Complete!\n";
    
     
Loading...

Share This Page