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.

scripts for permissions

Discussion in 'General Discussion' started by RCourtade, Dec 2, 2007.

  1. RCourtade

    RCourtade Registered

    Joined:
    Jul 29, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    I am looking for a way to mass update all public_html in the following ways:

    All files make 644
    All directories make 775

    I enabled phpsuexec and now have errors everywhere so I believe this should fix it. Any ideas?

    Ryan
     
  2. gupi

    gupi Well-Known Member

    Joined:
    Apr 27, 2004
    Messages:
    125
    Likes Received:
    0
    Trophy Points:
    16
    This should do the job

    Code:
    chmod -R 755 /home/*/public_html/
    chmod -R 644 /home/*/public_html/*.*
    however, double check on a few specific users
     
  3. Sindorf

    Sindorf Member

    Joined:
    Aug 3, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    The permission issue is a major problem on linux servers. I think there are a lot of solutions for this, but several months ago I have search through this forum and found some scripts to solve this problem.

    Actually, the scripts on this forum doesn't solve what I want (and people generally want) so I went through writing my own script by modifing the previous scripts I have found on this forum.

    Here they are;

    1. CHOWN script:

    Code:
    #!/bin/bash
    x=0
    cd /var/cpanel/users
    for user in *
    do
    echo "Working on account $user"
    chown -R $user.$user /home/$user/public_html/*
    echo "Account $user is finished"
    x=$(($x + 1))
    done
    echo "$x accounts are processed by CHOWN"
    cd ~
    
    2. CHMOD script:

    Code:
    #!/bin/bash
    x=0
    cd /var/cpanel/users
    for user in *
    do
    echo "Working on account $user"
    find /home/$user/public_html -depth -type d -exec chmod 755 {} \;
    find /home/$user/public_html -depth -type f -exec chmod 644 {} \;
    echo "Account $user is finished"
    x=$(($x + 1))
    done
    echo "$x accounts are processed by CHMOD"
    cd ~
    
    I know these are not so good scripts, these are my first bash scripts :) I think it is easy to modify these for any purpose that is related with cPanel accounts.

    I have tried these on several servers and they have worked perfectly.
     
  4. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    After doing that I'd recommend running the following script that will ensure that the main directories retain the correct ownership and permissions:

    /scripts/chownpublichtmls
     
  5. tomfra

    tomfra Well-Known Member

    Joined:
    Sep 30, 2002
    Messages:
    62
    Likes Received:
    0
    Trophy Points:
    6
    I personally got tired of the "file ownership hell" - i.e. when you FTP some files to your account, it's owned by your own username but then when you need some PHP script to write some files you've got a problem because Apache+PHP normally run as user "nobody". Plus there is the quota problem.

    So in the end I switched to FCGI and everything is working as it should now. So far I have had no serious problem with the setup. "public_html" has to be owned by USERNAME, group NOBODY, but all the files below it are simply owned by USERNAME.

    Works like a charm...

    Tomas
     
Loading...

Share This Page