20181123基本权限FACL
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了20181123基本权限FACL相关的知识,希望对你有一定的参考价值。
文件权限管理之:ACL设置基本权限
ACL的基本用法:
1.设置权限:
[[email protected] ~]# setfacl -m u:dong1:rw /home/test.txt
2.查看:
[[email protected] ~]# getfacl /home/test.txt
getfacl: Removing leading ‘/‘ from absolute path names
#file: home/test.txt
#owner: root
#group: root
user::rw-
user:dong1:rw-
group::r--
mask::rw-
other::r-
3.测试
[[email protected] home]$ vim /home/test.txt
实例1:用户设置权限
[[email protected] ~]# setfacl -m u:hr01:rwx /home/test.txt
[[email protected] ~]# getfacl /home/test.txt
getfacl: Removing leading ‘/‘ from absolute path names
#file: home/test.txt
owner: root
group: root
user::rw-
user:dong1:rw-
user:hr01:rwx
group::r--
mask::rwx
other::r--
实例2:给组设置权限
[[email protected] ~]# setfacl -m g:hr:rwx /home/test.txt
[[email protected] ~]# getfacl /home/test.txt
getfacl: Removing leading ‘/‘ from absolute path names
#file: home/test.txt
#owner: root
#group: root
user::rw-
user:dong1:rw-
user:hr01:rwx
group::r--
group:hr:rwx
mask::rwx
other::r--
4.删除用户对这个文件的权限:
[[email protected] ~]# setfacl -x u:dong1 /home/test.txt
[[email protected] ~]# getfacl /home/test.txt
getfacl: Removing leading ‘/‘ from absolute path names
file: home/test.txt
#owner: root
#group: root
user::rw-
user:hr01:rwx
group::r--
group:hr:rwx
mask::rwx
other::r--
5.取消其他人的任何权限
[[email protected] ~]# setfacl -m o:- /home/test.txt
[[email protected] ~]# getfacl /home/test.txt
getfacl: Removing leading ‘/‘ from absolute path names
#file: home/test.txt
#owner: root
#group: root
user::rw-
user:hr01:rwx
group::r--
group:hr:rwx
mask::rwx
other::---
6.清除所有的设置
[[email protected] ~]# setfacl -b /home/test.txt
[[email protected] ~]# ll /home/test.txt
-rw-r-----. 1 root root 5 11月 6 07:25 /home/test.txt
7.复制FACL
[[email protected] ~]# setfacl -m u:dong1:rwx,u:hr01:rw /home/test.txt
[[email protected] ~]# setfacl -m g:hr:rw,g:hr01:r /home/test.txt
[[email protected] ~]# getfacl /home/test.txt
getfacl: Removing leading ‘/‘ from absolute path names
file: home/test.txt
#owner: root
#group: root
user::rw-
user:dong1:rwx
user:hr01:rw-
group::r--
group:hr01:r--
group:hr:rw-
mask::rwx
other::---
[[email protected] ~]# getfacl /home/test.txt | setfacl --set-file=- /home/test1.txt
查看test1.txt的权限,与test.txt完全一样
[[email protected] ~]# getfacl /home/test1.txt
getfacl: Removing leading ‘/‘ from absolute path names
#file: home/test1.txt
#owner: root
#group: root
user::rw-
user:dong1:rwx
user:hr01:rw-
group::r--
group:hr01:r--
group:hr:rw-
mask::rwx
other::---
以上是关于20181123基本权限FACL的主要内容,如果未能解决你的问题,请参考以下文章