linux p4 拉分支,005. Linux基础五 P4 (ACL)

1 ACL

ACL生效顺序:

所有者,自定义用户,所属组|自定义组,其他人

setfacl 可以设置ACL权限

getfacl 可查看设置的ACL权限

[root@centos7 dir3]# getfacl a

# file: a

# owner: root

# group: root

user::rw-

user:docker1:---

group::r--

mask::r--

other::r--

[root@centos7 dir3]# setfacl -m g:admins:5 a

[root@centos7 dir3]# getfacl a

# file: a

# owner: root

# group: root

user::rw-

user:docker1:---

group::r--

group:admins:r-x

mask::r-x

other::r--

setfacl -b a #清除所有ACL权限

getfacl file1 | setfacl --set-file=-file2 #复制file1的acl权限给file2

mask权限

mask 权限

mask只影响除所有者和other的之外的人和组的最大权限

mask需要与用户的权限进行逻辑与运算后,才能变成有限的权限(Effective Permission)

用户或组的设置必须存在于mask权限设定范围内才会生效 [root@centos7 dir3]# setfacl -m mask::rx a

[root@centos7 dir3]# getfacl a

# file: a

# owner: root

# group: root

user::rw-

user:docker1:---

group::r--

group:admins:r-x

mask::r-x

other::r--

--set

--set选项会把原有的ACL项都删除,用新的替代,需要注意的是一定要包含UGO的设置,不能象-m一样 只是添加ACL就可以

setfacl --set u::rw,u:wang:rw,g::r,o::- file1

备份和还原ACL

#备份ACL getfacl -R /tmp/dir > acl.txt

#消除ACL权限 setfacl -R -b /tmp/dir

#还原ACL权限 setfacl -R --set-file=acl.txt

#还原ACL权限 setfacl --restore acl.txt

#查看ACL权限 getfacl -R /tmp/dir

练习

在/testdir/dir里创建的新文件自动属于webs组,组apps的成员如:tomcat能对这些新文件有读写 权限,组dbs的成员如:mysql只能对新文件有读权限,其它用户(不属于webs,apps,dbs)不能 访问这个文件夹 [root@centos7 ~]# mkdir -p /testdir/dir

[root@centos7 ~]# groupadd webs

[root@centos7 ~]# chgrp webs /testdir/dir

[root@centos7 ~]# chmod g+s /testdir/dir

[root@centos7 ~]# groupadd apps;groupadd dbs

[root@centos7 ~]# useradd -G apps tomcat;useradd -G dbs mysql

[root@centos7 ~]# setfacl -d -m g:apps:rw /testdir/dir

[root@centos7 ~]# setfacl -d -m g:dbs:r /testdir/dir

[root@centos7 ~]# chmod o= /testdir/dir

误将 /bin/chmod 文件的执行权限删除,如何恢复? install /usr/bin/chmod -m 744 /chmod

#在用install指令拷贝时指定权限,趁此时假如执行权限

mv /chmod /usr/bin/chmod

mv:是否覆盖"/usr/bin/chmod"? y

#用mv命令将先前的chmod覆盖

ll /usr/bin/chmod

-rwxr--r--. 1 root root 58584 3月 16 16:39 /usr/bin/chmod

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值