Linux setfacl/getfacl命令详解

setfacl,命令名,设置文件访问控制列表,即ACL规则。而Acl(Access Control List)就是访问控制列表

setfacl常见命令参数

setfacl 2.2.51 -- 设定文件访问控制列表

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

用法: 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              显示本帮助信息

getfacl常见命令参数

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

getfacl 2.2.49 -- get file access control lists

Usage: getfacl [-aceEsRLPtpndvh] file ...

  -a,  --access           display the file access control list only

  -d, --default           display the default access control list only

  -c, --omit-header       do not display the comment header

  -e, --all-effective     print all effective rights

  -E, --no-effective      print no effective rights

  -s, --skip-base         skip files that only have the base entries

  -R, --recursive         recurse into subdirectories

  -L, --logical           logical walk, follow symbolic links

  -P, --physical          physical walk, do not follow symbolic links

  -t, --tabular           use tabular output format

  -n, --numeric           print numeric user/group identifiers

  -p, --absolute-names    don't strip leading '/' in pathnames

  -v, --version           print version and exit

  -h, --help              this help text

常用的命令展示

获取文件的ACL

1

2

[root@localhost omc]# touch hhh

[root@localhost omc]# getfacl hhh

Linux setfacl/getfacl命令详解_第1张图片

更改文件的ACL,添加一个用户的权限

1

2

[root@localhost ~]#   setfacl -m u:omc:rwx hhh

[root@localhost ~]#  setfacl -m g:omc:r-w test      #添加一个组[root@localhost ~]#  getfacl hhh

Linux setfacl/getfacl命令详解_第2张图片

你可能感兴趣的:(『,GlusterFS』)