本文小编为大家详细介绍“Linux的setfacl命令怎么使用”,内容详细,步骤清晰,细节处理妥当,希望这篇“Linux的setfacl命令怎么使用”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。
setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...
-m, --modify=acl 更改文件的访问控制列表
-M, --modify-file=file 从文件读取访问控制列表条目更改
-x, --remove=acl 根据文件中访问控制列表移除条目
-X, --remove-file=file 从文件读取访问控制列表条目并删除
-b, --remove-all 删除所有扩展访问控制列表条目
-k, --remove-default 移除默认访问控制列表
--set=acl 设定替换当前的文件访问控制列表
--set-file=file 从文件中读取访问控制列表条目设定
--mask 重新计算有效权限掩码
-n, --no-mask 不重新计算有效权限掩码
-d, --default 应用到默认访问控制列表的操作
-R, --recursive 递归操作子目录
-L, --logical 依照系统逻辑,跟随符号链接
-P, --physical 依照自然逻辑,不跟随符号链接
--restore=file 恢复访问控制列表,和“getfacl -R”作用相反
--test 测试模式,并不真正修改访问控制列表属性
-v, --version 显示版本并退出
-h, --help 显示本帮助信息
例1
[root@localhost ~]# getfacl test
# file: test
# owner: root
# group: root
user::r-x
user:tank:rwx #effective:---
group::r-x #effective:---
mask::---
other::---
[root@localhost ~]# setfacl -m u:zhangy:rw- test #修改文件的acl权限,添加一个用户权限
[root@localhost ~]# getfacl test
# file: test
# owner: root
# group: root
user::r-x
user:zhangy:rw- #多出来一个用户
user:tank:rwx
group::r-x
mask::rwx
other::---
[root@localhost ~]# setfacl -m g:zhangying:r-w test #添加一个组
[root@localhost ~]# getfacl test
# file: test
# owner: root
# group: root
user::r-x
user:zhangy:rw-
user:tank:rwx
group::r-x
group:zhangying:rw-
mask::rwx
other::---
最后更新 2013-05-03 15:05:42 - 合作编辑者如下:张映
有误,我来改正
(0)
正确
(21)
例2
[root@localhost ~]# getfacl test #查看acl
# file: test
# owner: root
# group: root
user::rw-
group::r--
other::r--
[root@localhost ~]# setfacl -m u:tank:rx test #给tank用户向test文件增加读和执行的acl规则
[root@localhost ~]# getfacl test #查看acl
# file: test
# owner: root
# group: root
user::rw-
user:tank:r-x #已加入
group::r--
mask::r-x
other::r--
[root@localhost ~]# setfacl -m u::rwx test #设置默认用户,读,写,可执行
[root@localhost ~]# getfacl test
# file: test
# owner: root
# group: root
user::rwx
user:tank:r-x
group::r--
mask::r-x
other::r--
[root@localhost ~]# setfacl -b test #清除所有acl
[root@localhost ~]# getfacl test
# file: test
# owner: root
# group: root
user::rwx
group::r--
other::r--
[root@localhost ~]# setfacl -m u:tank:rx test #给tank用户向test文件增加读和执行的acl规则
[root@localhost ~]# setfacl -m u:testtank:rx test #给testtank用户向test文件增加读和执行的acl规则
[root@localhost ~]# getfacl test
# file: test
# owner: root
# group: root
user::rwx
user:testtank:r-x
user:tank:r-x
group::r--
mask::r-x
other::r--
[root@localhost ~]# setfacl -x u:tank test #清除tank用户,对test文件acl规则
[root@localhost ~]# getfacl test
# file: test
# owner: root
# group: root
user::rwx
user:testtank:r-x
group::r--
mask::r-x
other::r--
读到这里,这篇“Linux的setfacl命令怎么使用”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注亿速云行业资讯频道。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。