005. Linux基础五 P4 (ACL)

时间:2020-11-10 11:23:45   收藏:0   阅读:15
1 ACL

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 权限

备份和还原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

练习

  1. 在/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
  2. 误将 /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
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!