- getfacl:取得某个文件/目录的 ACL 配置项目;
- setfacl:配置某个目录/文件的 ACL 规范。
# 1. 针对特定使用者的方式: # 配置规范:『 u:[使用者账号列表]:[rwx] 』,例如针对 vbird1 的权限规范 rx : [root@www ~]# touch acl_test1 [root@www ~]# ll acl_test1 -rw-r--r-- 1 root root 0 Feb 27 13:28 acl_test1 [root@www ~]# setfacl -m u:vbird1:rx acl_test1 [root@www ~]# ll acl_test1 -rw-r-xr--+ 1 root root 0 Feb 27 13:28 acl_test1 # 权限部分多了个 + ,且与原本的权限 (644) 看起来差异很大!但要如何查阅呢? [root@www ~]# setfacl -m u::rwx acl_test1 [root@www ~]# ll acl_test1 -rwxr-xr--+ 1 root root 0 Feb 27 13:28 acl_test1 # 无使用者列表,代表配置该文件拥有者,所以上面显示 root 的权限成为 rwx 了!
上述动作为最简单的 ACL 配置,利用『 u:使用者:权限 』的方式来配置的啦!
[root@www ~]# getfacl filename 选项与参数: getfacl 的选项几乎与 setfacl 相同!所以鸟哥这里就免去了选项的说明啊! # 请列出刚刚我们配置的 acl_test1 的权限内容: [root@www ~]# getfacl acl_test1 # file: acl_test1 <==说明档名而已! # owner: root <==说明此文件的拥有者,亦即 ll 看到的第三使用者字段 # group: root <==此文件的所属群组,亦即 ll 看到的第四群组字段 user::rwx <==使用者列表栏是空的,代表文件拥有者的权限 user:vbird1:r-x <==针对 vbird1 的权限配置为 rx ,与拥有者并不同! group::r-- <==针对文件群组的权限配置仅有 r mask::r-x <==此文件默认的有效权限 (mask) other::r-- <==其他人拥有的权限啰!
# 2. 针对特定群组的方式: # 配置规范:『 g:[群组列表]:[rwx] 』,例如针对 mygroup1 的权限规范 rx : [root@www ~]# setfacl -m g:mygroup1:rx acl_test1 [root@www ~]# getfacl acl_test1 # file: acl_test1 # owner: root # group: root user::rwx user:vbird1:r-x group::r-- group:mygroup1:r-x <==这里就是新增的部分!多了这个群组的权限配置! mask::r-x other::r--
mask 是什么东西啊?其实他有点像是『有效权限』的意思!他的意义是:使用者或群组所配置的权限必须要存在于 mask 的权限配置范围内才会生效,此即『有效权限 (effective permission)』我们举个例子来看,如下所示:
# 3. 针对有效权限 mask 的配置方式: # 配置规范:『 m:[rwx] 』,例如针对刚刚的文件规范为仅有 r : [root@www ~]# setfacl -m m:r acl_test1 [root@www ~]# getfacl acl_test1 # file: acl_test1 # owner: root # group: root user::rwx user:vbird1:r-x #effective:r-- <==vbird1+mask均存在者,仅有 r 而已! group::r-- group:mygroup1:r-x #effective:r-- mask::r-- other::r-- |
如果你想要让 acl 在目录底下的数据都有继承的功能,那就得如下这样做了!
# 4. 针对默认权限的配置方式: # 配置规范:『 d:[ug]:使用者列表:[rwx] 』 # 让 myuser1 在 /srv/projecta 底下一直具有 rx 的默认权限! [root@www ~]# setfacl -m d:u:myuser1:rx /srv/projecta如果想要让 ACL 的属性全部消失又要如何处理?透过『 setfacl -b 檔名 』即可