扩展文件权限ACL

来源:互联网 发布:人工智能机器人介绍 编辑:程序博客网 时间:2024/04/28 02:45


扩展文件权限


功能说明

一般的问题属性定义为
rwx(Owner)r-x(Group)r-x(Other)

当这样定义时,group和other无法精确到具体的用户或组,所以在给予权限和文件安全上存在冲突,所以需要通过ACL来设置文件扩展属性,
在linux安全模型薄弱的时候,ACL是一个非常好的管理文件权限的功能


命令及用法

setfacl 用于设置文件的ACL规则,添加和删除组、用户的权限
getfacl 用于查询

setfacl [options] id:operand filename

setfacl -m u:UID:PERM
setfacl -m g:GID:PERM

举个栗子

setfacl -m u:dsware:rw- /root/123.sh  给dsware用户加读写权限
setfacl -m g:omm:r-x /root/123.sh  给omm组加读写权限
setfacl -m m::r-- /root/123.sh   有效权限位,mask范围以内
setfacl -m d:u:dsware:r-- /root/test   给目录添加默认acl

setfacl -x u:dsware /root/123.sh 移除权限
setfacl -x g:omm /root/123.sh

getfacl /root/123.sh  查询

0 0