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.

Change file permissions on all files with a certain name

Discussion in 'Security' started by felixr, Feb 2, 2015.

  1. felixr

    felixr Registered

    Joined:
    Feb 2, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi. Is there way I can change all file permissions on a certain file name easily (without doing them 1 by 1)? Eg search /home and change all files found that match "wp-config.php"

    We have a vps with 40+ wordpress installations and want to change all the wp-config.php permissions to 400.

    Thanks
     
  2. quizknows

    quizknows Well-Known Member

    Joined:
    Oct 20, 2009
    Messages:
    940
    Likes Received:
    55
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Before I tell you how to do this, I'll just state that it's basically useless from a security standpoint if you want to do it with wp-config files. In most cases if you use SuPHP (which most people do) the sites user still owns the file, and a hack script can still access the file, or change its permissions back to writeable.

    Anyway, it's a simple find command, but standard caveats of root shell access apply.
    Code:
    # find /home/*/public_html/ -type f -name wp-config.php -exec chmod 400 '{}' \;
    
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    In addition to the previous thread, if you are looking to improve overall security, check out the cPanel Security Advisor for some useful tips:

    "WHM Home » Security Center » Security Advisor

    Thank you.
     
  4. felixr

    felixr Registered

    Joined:
    Feb 2, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thanks for that quizknows, it worked. :)


    CpanelMichael - Thanks, but yes i've done that.
     
Loading...

Share This Page