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. Linux系统教程 标准输入/输出和重定向

    1. 标准输入与输出 我们知道,执行一个shell命令行时通常会自动打开三个标准文件,即标准输入文件(stdin),通常对应终端的键盘:标准输出文件(stdout)和标准错误输出文件(stderr), ...

  2. HDU2669 Romantic 扩展欧几里德 对我来说有陷阱

    这道题对我来说有陷阱虽说是赤果果的扩展欧几里德,看样子基本攻还是不够哈,基本功夫一定要好,准备每天上那种洗脑课时分  多看看数论书,弥补一下 自己 狗一样的基础, 这道题用到了一个性质: 对于不定整数 ...

  3. 2018CVPR

    CVPR 2018:腾讯图像去模糊.自动人像操纵最新研究 解密运动模糊:走向实用的非特定场景图片去模糊技术 在慢速曝光或快速运动拍摄照片时,图像模糊常常困扰着照片拍摄者.优图实验室的研究人员开发了可以 ...

  4. ItemsControl

    <ItemsControl Grid.Row=" ItemsSource="{Binding Content.patientInfoList}" Width=&qu ...

  5. java 正则表达式获得html字符串中<img src>中的src中的url地址

    public static Set<String> getImgStr(String htmlStr) { Set<String> pics = new HashSet< ...

  6. Python访问PostGIS(建表、空间索引、分区表)

    #encoding: utf-8 __author__ = 'Administrator' import psycopg2 import ppygis import datetime import s ...

  7. STS 控制台 中文乱码(maven 中文乱码)

    用uriEncoding标签设置中文字符集就行了 <plugin> <groupId>org.apache.tomcat.maven</groupId> <a ...

  8. JavaSE入门学习17:Java面向对象之package(包)

           一Java包(package)        为了更好地组织类,Java提供了包机制,用于差别类名的命名空间.        包的作用:        A把功能类似或相关的类或接口组织在 ...

  9. ecipse theme

    市场里搜“jeeeyul's Eclipse Themes”

  10. s[-1]和s[len(s)-1]

    Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32 Type "copyr ...