一不小心把文件和目录权限弄错了,想恢复回原有的样子,只需要执行一条命令即可恢复:

find folder '(' -type f -exec chmod 644 {} ';' ')' -o '(' -type d -exec chmod 755 {} ';' ')'

这条命令其实是两条命令合成的:

find folder -type d -exec chmod 755 {} \;
find folder -type f -exec chmod 644 {} \;

-o means OR. This command processes all objects in the project tree that are of type “file” or type “directory”, and executes different commands based on which type each object is.

You can make this slightly more efficient by replacing the semicolons (';') with plus signs (+); this tells find to run chmod 644 once, with all the plain files’ names as arguments, and to run chmod 755 once, with all the directories’ names as arguments.

查看原文

发表评论