如何找到chmod 444并将其设置为目录中的所有.htaccess文件(出于安全目的)?
感谢。
答案 0 :(得分:5)
如果您可以访问SSH,则可以执行以下操作:
find . -name .htaccess | xargs chmod 444
对从您运行命令的当前目录中找到的所有chmod
文件递归执行.htaccess
。
如果要指定文件夹,可以这样做:
find /home/your_account/public_html -name .htaccess | xargs chmod 444
您还可以在使用命令之前列出文件,以确保它符合您的需求:
find . -name .htaccess -print
或使用文件夹路径:
find /home/your_account/public_html -name .htaccess -print
例如,如果您在以下位置运行了第一个提到的命令:
/home/your_account/public_html
它会从该文件夹和.htaccess
上方的任何其他文件夹中提供chmod 444
个文件,因此:
/home/your_account/public_html
/home/your_account/public_html/other_dir
/home/your_account/public_html/other_dir2
/home/your_account/public_html/other_dir/other_inner_dir
等等。