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.

How to copy one file to all cpanel accounst on single vps at once?

Discussion in 'General Discussion' started by T2CFNOW, Jan 24, 2012.

  1. T2CFNOW

    T2CFNOW Registered

    Joined:
    Jan 24, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Two commands would be needed:

    Code:
    for i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do cp /pathtofile /home/$i/public_html ;done
    for i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do chown $i:$i /home/$i/public_html/filename ;done
    Replace pathtofile with the path to the file you are copying, and replace filename with the name fo the file. The first command performs the copy by obtaining a list of the account usernames on the machine. The second command chowns the file to the user.
     
  3. madpato

    madpato Active Member

    Joined:
    May 30, 2008
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    HI

    I am trying to do this but to all accounts belonging to a certain reseller i believe i should use /etc/trueuserowners for this but im not sure if the same rest of the command would be the same, something like:

    Code:
    for i in `cat /etc/trueuserowners | grep reselleraccount | cut -d: -d' ' -f2-` ;do cp /pathtofile /home/$i/public_html ;done
    Thank you for help.
     
  4. madpato

    madpato Active Member

    Joined:
    May 30, 2008
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    I figured it out its almost the same:

    Code:
    for i in `cat /etc/trueuserowners | grep reselleraccount | cut -d':' -f1` ;do cp pathtofile /home/$i/public_html ;done
    for i in `cat /etc/trueuserowners | grep reselleraccount | cut -d':' -f1` ;do chown $i:$i /home/$i/public_html/filename ;done
    
    I hope its useful for someone.
     
  5. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Please note that if you are want this to be done on new account creation, you should put the file into /root/cpanel3-skel/public_html directory and it will be created for all new accounts.

    If you'd like to copy a file into all new reseller created accounts instead, you'd put the file into /home/username/cpanel3-skel/public_html (you'll have to create cpanel3-skel/public_html folders on that reseller user and here username is the reseller's username).
     
Loading...

Share This Page