chmod - 将用户权限复制到 group/world

chmod - replicate user permissions to group/world

我需要使某些 folders/files(递归)具有与用户相同的权限。所以:

我该怎么做?也许我知道一些秘密命令?

如果没有简单的方法,那么我可能需要创建一个循环并 test/assign。最终我只需要处理3种类型:

文件夹应为 777,大多数文件应为 666,可执行文件应为 777。

没有适合您的命令。你确实需要一个小循环:

for file in $(find . -print)
do
  if [ -d $file -o -x $file ]; then
    chmod 777 $file
  else
    chmod 666 $file
  fi
done

find 可以找到具有给定权限集的文件和 运行 覆盖它们所需的最小可能数量的 chmod 调用。

find . \
  '(' -perm -0700 -exec chmod 0777 '{}' + ')' -o \
  '(' -perm -0600 -exec chmod 0666 '{}' + ')'