20181123基本權限FACL
ACL的基本用法:
1.設置權限:
[root@dong ~]# setfacl -m u:dong1:rw /home/test.txt
2.查看:
[root@dong ~]# 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.測試
[dong1@dong home]$ vim /home/test.txt
實例1:用戶設置權限
[root@dong ~]# setfacl -m u:hr01:rwx /home/test.txt
[root@dong ~]# 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:給組設置權限
[root@dong ~]# setfacl -m g:hr:rwx /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.刪除用戶對這個文件的權限:
[root@dong ~]# setfacl -x u:dong1 /home/test.txt
[root@dong ~]# getfacl /home/test.txt
file: home/test.txt
#owner: root
#group: root
user::rw-
user:hr01:rwx
group::r--
group:hr:rwx
mask::rwx
other::r--
5.取消其他人的任何權限
[root@dong ~]# setfacl -m o:- /home/test.txt
[root@dong ~]# 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.清除所有的設置
[root@dong ~]# setfacl -b /home/test.txt
[root@dong ~]# ll /home/test.txt
-rw-r-----. 1 root root 5 11月 6 07:25 /home/test.txt
7.復制FACL
[root@dong ~]# setfacl -m u:dong1:rwx,u:hr01:rw /home/test.txt
[root@dong ~]# setfacl -m g:hr:rw,g:hr01:r /home/test.txt
[root@dong ~]# 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::---
[root@dong ~]# getfacl /home/test.txt | setfacl --set-file=- /home/test1.txt
查看test1.txt的權限,與test.txt完全一樣
[root@dong ~]# 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