linux,acl的管理需要用到两个命令,getfacl,setfacl
getfacl命令较简单,# getfacl path 即可
主要是setfacl命令有些问题,
当你给一个文件设置用户或组的ACL权限时,可以用其UID/GID 即数字,也可以用name
比如用户test的uid为101,下面两个命令都可以设置test的ACL
/bin/bash# setfacl -m u:101:rw- file.path
/bin/bash# setfacl -m u:test:rw- file.path
读取其ACL为:
/bin/bash# getfacl filepath
# file: filepath
# owner: root
# group: root
user::rw-
user:test:rw-
group::r--
mask::rw-
other::r--
问题在于新建一个用户名为101的用,然后再设ACL时,会发现设置失败
/bin/bash# setfacl -m u:101:r-x filepath
/bin/bash# getfacl filepath
# file: filepath
# owner: root
# group: root
user::rw-
user:test:rw-
group::r--
mask::rw-
other::r--
这时候只能用用户101的UID,来设置ACL
/bin/bash# setfacl -m u:502:r-x filepath
/bin/bash# getfacl filepath
# file: filepath
# owner: root
# group: root
user::rw-
user:test:rw-
user:101:r-x
group::r--
mask::rw-
other::r--
所以,如果不能保证用户里面没有全数字用户名,先获取用户UID再设置ACL比较保险。