Change file permissions on all files with a certain name

felixr

Registered
Feb 2, 2015
4
0
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
 

quizknows

Well-Known Member
Oct 20, 2009
1,008
87
78
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 '{}' \;
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,226
463
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.