ACL允许向文件分配细化的权限。除标准的文件所有者、组所有者、和其他文件权限之外,还可以指定用户或组,以及uid或guid确定的用户和组授予权限。

命令:

·setfacl 设置acl策略

·getfacl 查看acl策略

[root@server ~]# setfacl --help
setfacl 2.2. -- set file access control lists
Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...
-m, --modify=acl modify the current ACL(s) of file(s) #设置文件或目录ACL规则
-M, --modify-file=file read ACL entries to modify from file #从文件读取ACL规则
-x, --remove=acl remove entries from the ACL(s) of file(s) #删除ACL规则
-X, --remove-file=file read ACL entries to remove from file #从文件读取ACL规则,并且进行删除
-b, --remove-all remove all extended ACL entries #删除所有扩展ACL规则,基本ACL规则保留
-k, --remove-default remove the default ACL #删除默认ACL规则,如果没有默认ACL规则,不提示
--set=acl set the ACL of file(s), replacing the current ACL #
--set-file=file read ACL entries to set from file
--mask do recalculate the effective rights mask #重新计算有效权限,即使ACL Mask被明确指定
-n, --no-mask don't recalculate the effective rights mask #不要重新计算有效权限
-d, --default operations apply to the default ACL #设置默认ACL规则,只是针对目录而言
-R, --recursive recurse into subdirectories #递归设置ACL规则
-L, --logical logical walk, follow symbolic links
-P, --physical physical walk, do not follow symbolic links
--restore=file restore ACLs (inverse of `getfacl -R')
--test test mode (ACLs are not modified)
-v, --version print version and exit
-h, --help this help text
[root@server ~]# mkdir /sharedata
[root@server ~]# cp /etc/passwd /sharedata/
[root@server ~]# useradd usera
[root@server ~]# useradd userb
[root@server ~]# useradd userc
[root@server ~]# echo 'userabc' |passwd --stdin usera
Changing password for user usera.
passwd: all authentication tokens updated successfully.
[root@server ~]# echo 'userabc' |passwd --stdin userb
Changing password for user userb.
passwd: all authentication tokens updated successfully.
[root@server ~]# echo 'userabc' |passwd --stdin userc
Changing password for user userc.
passwd: all authentication tokens updated successfully.
[root@server ~]# cd /sharedata/
[root@server sharedata]# ll
total
-rw-r--r-- root root Oct : passwd
[root@server sharedata]# setfacl -m u:usera:r passwd
[root@server sharedata]# setfacl -m u:userb:rw passwd
[root@server sharedata]# setfacl -m u:userc:rwx passwd
[root@server sharedata]# getfacl passwd
# file: passwd
# owner: root
# group: root
user::rw-
user:usera:r--
user:userb:rw-
user:userc:rwx
group::r--
mask::rwx
other::r--

如果想让ACL在目录下的数据都有继承功能,通常会对这个目录设置默认权限

文件所有者可以在单个文件或目录上设置ACL。新文件和子目录可以自动从父目录默认ACL中继承ACL设置。 与常规文件的访问规则类似,父目录层次结构需要至少设置其它执行权限,以便启用指定用户和指定组的访问权限。

[root@server ~]# mkdir /sharedata
[root@server sharedata]# setfacl -m d:u:usera:rwx /sharedata/
[root@server sharedata]# su - usera
Last login: Thu Oct :: CST on pts/
[usera@server ~]$ cd /sharedata/
[usera@server sharedata]$ touche usera
bash: touche: command not found...
Similar command is: 'touch'
[usera@server sharedata]$ touch usera
touch: cannot touch ‘usera’: Permission denied
[usera@server sharedata]$ exit
logout
[root@server sharedata]# mkdir -p /sharedata/pub
[root@server sharedata]# su - usera
Last login: Thu Oct :: CST on pts/
[usera@server ~]$ cd /sharedata/pub/
[usera@server pub]$ touch usera
[usera@server pub]$ cd ..
[usera@server sharedata]$ touch usera
touch: cannot touch ‘usera’: Permission denied

ACL掩码
掩码定义可授予指定用户组、组所有者和指定组的最大权限。不限制文件所有者或其它用户的权限
如果设置了mask,和mask比较,最终取得是二者中最小权限

[root@server /]# cd sharedata/
[root@server sharedata]# cp /etc/passwd .
[root@server sharedata]# setfacl -m u:usera:r passwd
[root@server sharedata]# setfacl -m u:userb:rw passwd
[root@server sharedata]# setfacl -m u:userc:rwx passwd
[root@server sharedata]# getfacl passwd
# file: passwd
# owner: root
# group: root
user::rw-
user:usera:r--
user:userb:rw-
user:userc:rwx
group::r--
mask::rwx
other::r-- [root@server sharedata]# setfacl -m m:r passwd
[root@server sharedata]# getfacl passwd
# file: passwd
# owner: root
# group: root
user::rw-
user:usera:r--
user:userb:rw- #effective:r--
user:userc:rwx #effective:r--
group::r--
mask::r--
other::r-- [root@server sharedata]# setfacl -m m:rwx passwd
[root@server sharedata]# getfacl passwd
# file: passwd
# owner: root
# group: root
user::rw-
user:usera:r--
user:userb:rw-
user:userc:rwx
group::r--
mask::rwx
other::r--

RHCE7 管理II-6ACL的使用的更多相关文章

  1. RHCE7 管理II-4计划将来的Linux任务

    (1) at 一次性的计划任务 语法: # at [参数] [时间] at> 执行的指令 退出at命令 ctrl+d [root@localhost ~]# at now at> mkdi ...

  2. RHCE7 管理I-12归档文件并在Linux系统间复制文件

    tar命令使用 默认tar只有归档的功能,没有压缩功能 tar [option...] [file]... -c,--create     创建 -x,--extract,--get   解压 -t, ...

  3. RHCE7 管理II-5管理进程的优先级

    进程的优先级值称为进程的nice值,共有40种不同的取值(用数字-20到19表示) nice值越大,表示进程的优先级越低. 进程的nice值,只允许root用户来设置负的nice:其他用户只允许设置正 ...

  4. RHCE7 管理II-2 通过grep使用正则表达式

    grep -i:忽略大小写 -n:表示行数 找出含有root的行 # grep root /etc/passwd root:x:::root:/root:/bin/bash ::operator:/r ...

  5. RHCE7 管理II-3使用VIM编辑器

    vim的不同版本: 1.vim-minial 提供vi和相关命令.在RHEL 7的最小安装中 2.vim-enhanced 提供vim命令.提供语法突出显示.文件类型插件和拼写检查等功能 3.vim- ...

  6. phper 要求

    做了这么多年php,今天看到一个07年的老文,才发现自己的水平太菜.转过来激励下自己 说句实话,写这个真够无聊的.本来看了某位大虾的类似文章,腹诽了几句也就算了.但是昨天晚上有个客户拿着这篇文章问我: ...

  7. PHPer的等级划分

    PHPer的等级划分 前一段时间刚刚完成PHP的培训,然后想知道自己目前的水平(或者说等级),并且应该在哪些方面进行提高,所以在网上查了一下相关介绍.其中有一篇介绍讲的挺清楚的,至少目前的我还是很认同 ...

  8. java打包jar,war,ear包的作用、区别

    java的打包jar,war,ear包的作用,区别,打包方式. a) 作用与区别      i.    jar: 通常是开发时要引用通用(JAVA)类,打成包便于存放管理      ii.   war ...

  9. Spring_Aop的xml和注解的使用

    动态代理:    目的:在不改变源代码的情况下,对方法进行增强!        动态代理又分为两种:    1.第一个就是基于接口的动态代理,他是由jdk提供的    2.基于子类的动态代理:cgli ...

随机推荐

  1. Gson 使用总结 高级用法

    Gson基本用法 参考:http://www.jianshu.com/p/e740196225a4 Gson提供了fromJson() 和toJson() 两个直接用于解析和生成的方法,前者实现反序列 ...

  2. AngularJS 用 $http.jsonp 跨域SyntaxError问题

    必须添加参数:callback=JSON_CALLBACK , 才能进success方法,如下: $http.jsonp("https://request.address.json?call ...

  3. 科幻大片中那些牛X代码真相

    在<黑客帝国>中,救世主Neo的队友通过屏幕上"1"和"0"构成的数据流,就能看到鲜活的画面,这应该算是科幻大片中对代码最极致的表现了.其他科幻电影 ...

  4. Windows10下安装pytorch并导入pycharm

    1.安装Anaconda 下载:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 安装Anaconda3,最新版本的就可以了,我安装的是5. ...

  5. springboot securyt 默认的用户名和密码

    用户名:user 密码在控制台,每次启动的时候会生成一个随机的密码,如下:

  6. 【pyhon】理想论坛爬虫1.08

    #------------------------------------------------------------------------------------ # 理想论坛爬虫1.08,用 ...

  7. 整理两个PetaPoco连接SQLite数据库的方法

    从https://github.com/qingask/PetaPoco.NetCore下载源文件压缩包 解压出文件PetaPoco.Multiple.cs.PetaPoco.NetCore.cs 放 ...

  8. DEDE标签综合

    dede: sql标签: sql标签可以称得上是个万能标签了,查询数据库将其输出,这里介绍一些关于这个标签的用法: 1.用来输出统计内容,这个是不错的,举个例子,我们来统计下总共发了多少的文章,思路就 ...

  9. Discuz常见小问题-如何修改favourite图标

    1做好一个ico图标之后,直接替换目录下的对应文件即可, 如果没效果刷新浏览器或更新后台CSS缓存.

  10. VC操作MPP文件

    1.背景简介 因需要对Office系列进行程序操作,特需要使用COM编程. Microsoft Project生成进度计划,office家族软件,文件后缀为.mpp. 具体信息见维基百科http:// ...