如何chmod 755所有目录但没有文件(递归)?
相反,如何仅递归chmod文件,而没有目录chmod?
要递归地赋予目录读取和执行特权:
find /path/to/base/dir -type d -exec chmod 755 {} +
递归地授予文件读取权限:
find /path/to/base/dir -type f -exec chmod 644 {} +
或者,如果要处理的对象很多:
chmod 755 $(find /path/to/base/dir -type d)
chmod 644 $(find /path/to/base/dir -type f)
或者,为了减少chmod
产卵:
find /path/to/base/dir -type d -print0 | xargs -0 chmod 755
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句