Linux setfacl/getfacl命令详解

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

setfacl常见命令参数

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

用法: 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常见命令参数

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

[root@localhost omc]# touch hhh
[root@localhost omc]# getfacl hhh

image

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

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

image

【更多参考】http://linux.51yip.com/search/setfacl

posted @ 2018-07-07 11:23  小a玖拾柒  阅读(18996)  评论(0编辑  收藏  举报