3) 设置文件或目录的 ACL
用法:
setfacl [-bkndRLP] {-m|-M|-x|-X|...} file
常用选项:
-m: 设置或修改文件的 ACL 权限
-x: 删除文件的一个 ACL 权限
-b: 删除文件所有的 ACL 权限
-k: 删除所有的默认 ACL 权限
--set: 设置文件 ACL, 替代当前的 ACL
--mask: 重新计算有效的 mask 值
-R: 递归子目录
-d: 设置默认的 ACL 权限, 仅能针对目录使用
--restore: 从文件恢复备份的 ACL
例子: 查看和设置 ACL
针对用户 zhangsan 来设置 rwx
setfacl -m u:zhangsan:rwx acltest.file
针对组 nona 来设置 rw
setfacl -m g:nona:rw acltest.file
设置限制的权限为 r
setfacl -m m:r acltest.file (mask 为限制权限)
查看当前的 ACL
getfacl acltest.file
设置 ACL 权限, 如果同时设置多个权限, 权限之间使用 "," 分隔, 同时设置多个 ACL 用户和组的权限:
setfacl -m u:user1:rwx,u:user2:rw,u:user3:r,g:nona:rw testfile
删除 ACL 权限
setfacl -x g:zhangsan acltest.file
一次性删除所有 ACL 的权限
setfacl -b acltest.file
设置目录默认的 ACL
setfacl -d -m g:nona:rwx testdir/
来源: http://www.bubuko.com/infodetail-2599640.html