lee*_*d00 5 acl backup permissions
在 Windows 上修改权限时,我首先使用以下命令将 ACL 备份到文件:
subinacl /noverbose /output=C:\temp\foldername_redir_permissions_backup_star_star.txt /subdirectories "W:\foldername\*.*"
Run Code Online (Sandbox Code Playgroud)
和...
subinacl /noverbose /output=C:\temp\foldername_redir_permissions_backup.txt /subdirectories "W:\foldername\"
Run Code Online (Sandbox Code Playgroud)
...支持他们。
然后如果他们需要恢复,像这样的命令......
subinacl /playfile C:\temp\foldername_redir_permissions_backup_star_star.txt
Run Code Online (Sandbox Code Playgroud)
...可用于恢复它们。
那么对于 Linux / Unix 上的 POSIX 权限可以做同样的事情吗?那么 ACL 扩展权限呢?
setfacl
旨在接受getfacl
输出作为输入。这意味着您可以运行getfacl
,将输出保存到文件,做您的事情,然后恢复 ACL。确切的过程可能因您的平台而异。在 Linux 上:
# Take a peek at the current ACL
[root@vlp-fuger ~]# getfacl newFile
# file: newFile
# owner: root
# group: root
user::rw-
group::r--
group:provisor:rwx
mask::rwx
other::r--
# Backup ACL
[root@vlp-fuger ~]# getfacl newFile > newFile.acl
# Remove the group permission, add another that we'll later want to get rid of
[root@vlp-fuger ~]# setfacl -x g:provisor newFile
[root@vlp-fuger ~]# setfacl -m g:ihtxadm:r-x newFile
[root@vlp-fuger ~]# getfacl newFile
# file: newFile
# owner: root
# group: root
user::rw-
group::r--
group:ihtxadm:r-x
mask::r-x
other::r--
# Restore ACL to where it was
[root@vlp-fuger ~]# setfacl --restore=newFile.acl
# Resulting ACL
[root@vlp-fuger ~]# getfacl newFile
# file: newFile
# owner: root
# group: root
user::rw-
group::r--
group:provisor:rwx
mask::rwx
other::r--
Run Code Online (Sandbox Code Playgroud)
您也可以使用--set-file
在setfacl
您使用恢复并将它设置为-
,如果你想管旧ACL。您还可以使用getfacl -R
备份的ACL的的整个目录树。