有没有办法在Linux上recursion地转储整个目录的所有权和模式

我正在许多服务器上进行Samba更新,每个服务器都有几个共享目录。 用户通过Windows域AD进行身份validation,所以我期望Linux机器上本地UID的更改。 我想知道是否有方法来转储所有共享目录的所有权,所以我不必手动设置它,而是在升级后恢复它。

你可以通过使用脚本来完成。

1)转储文件中的目录(名称)。 2)使用find path -type d (这是打印path下的每个目录)。 3)find共同的元素,并应用ls -lah

一个肮脏的方式来做到这一点。 只有在绝望的情况下才推荐:>

你也可能会发现有用的find . -type d -print0 {} \; | xargs ls -lah find . -type d -print0 {} \; | xargs ls -lah

您可以使用getfacl工具(acl包的一部分)来转储和恢复正常的unix权限和acls:

使用getfacl -Rsetfacl --restore=file转储到文件中,并使用setfacl --restore=file来恢复它们:

  --restore=file Restore a permission backup created by 'getfacl -R' or similar. All permissions of a complete directory subtree are restored using this mechanism. If the input contains owner comments or group comments, setfacl attempts to restore the owner and owning group. If the input contains flags comments (which define the setuid, setgid, and sticky bits), setfacl sets those three bits accordingly; otherwise, it clears them. This option cannot be mixed with other options except '--test'. 

即使你没有设置acls,这个工具也会工作 – 这个工具会转储和恢复标准的unix fs权限。 如果您的文件系统没有启用acl支持,它也可以工作(对于大多数文件系统,这仍然是非默认挂载选项)

Solaris有一个优点,因为它有一个很好的命令叫pkgproto

但是你可以使用类似的东西

 find /home/elao/ -type d | xargs ls -lnd | awk '{print "chown "$3":"$4,$8}'