FACL(Filesystem Access Control List):利用文件扩展属性保存额外的访问控制权限
普通用户无法修改文件属主与属组
1. 读取文件权限列表
1-1. 权限列表是什么?
对于文件的权限进行附加补充说名的一个权限设定方式
1-2. FACL的来源
有两个普通用户tom、jerry,当tom由一个文件只想让jerry用户可以写入,其他普通用户只读,解决办法?
root用户,将jerry加入tom组中,但是如果不能登录root用户时该怎么办?
[root@aclhost ~]# useradd tom
[root@aclhost ~]# useradd jerry
[root@aclhost ~]# mkdir /test
[root@aclhost ~]# chmod 777 /test
[root@aclhost ~]# su - tom
Last login: Tue Oct 11 09:59:48 CST 2016 on pts/0
[tom@aclhost ~]$ touch /test/tom
[tom@aclhost ~]$ echo tom > /test/tom
[tom@aclhost ~]$ ll /test/tom
-rw-rw-r-- 1 tom tom 4 Oct 11 10:01 /test/tom
[root@aclhost ~]# su - jerry
[jerry@aclhost test]$ echo jerry >> tom
-bash: tom: Permission denied
1-3. 查看权限列表命令getfacl
[tom@aclhost ~]$ getfacl /test/tom
getfacl: Removing leading '/' from absolute path names
# file: test/tom
# owner: tom
# group: tom
user::rw-
group::rw-
other::r--
[root@aclhost mnt]# ls -l file
-rw-rw-r--<<+>> 1 root root 0 Nov 7 09:14 file
[root@aclhost mnt]# getfacl file
# file: file ##文件名称
# owner: root ##文件所有人,属主
# group: root ##文件所有组,属组
user::rw- ##所有人权限
user:student:rw- ##特定用户权限
group::r-- ##所有组权限
mask::rw- ##特定用户生效的最大权限,会随文件acl的改变而改变
other::r-- ##其他人权限
2. 设定权限列表
2-1. 对文件权限列表的操作(增、减、删)
setfacl -m
[tom@aclhost ~]$ setfacl -m u:jerry:rw /test/tom
[tom@aclhost ~]$ getfacl /test/tom
getfacl: Removing leading '/' from absolute path names
# file: test/tom
# owner: tom
# group: tom
user::rw-
user:jerry:rw-
group::rw-
mask::rw-
other::r--
[jerry@aclhost ~]$ echo jerry >> /test/tom
[jerry@aclhost ~]$ cat /test/tom
tom
jerry
无acl时权限应用次序:owner->group->other
有acl时权限应用次序:owner->facl user->group->facl group ->other
2-2. 设定文件的acl默认权限
默认权限针对目录使用,让目录中所有新建文件都继承此acl权限,这个权限对目录本身不生效,并且不会影响目录中已经存在的文件
setfacl -m d:
3. 设备权限列表加载
在rhel6以及之前的版本中,用户建立的分区时不支持acl的,如果需要,必须加载acl参数
mount -o remount,acl 设备
vim /etc/fstab
设备 挂载点 类型 defaults,acl 0 0