linux系統中的檔案訪問控制列表ACL
阿新 • • 發佈:2020-10-21
1、linux系統中普通許可權的設定主要是針對一類情形,比如針對所有者、所屬組或者其他人的設定。
linux系統中的檔案訪問控制列表是針對特定具體的使用者或者使用者組來進行許可權設定。
直接測試:
## 為了對比,先測試未分配ACL之前的情況
[root@linuxprobe test]# ls
[root@linuxprobe test]# whoami
root
[root@linuxprobe test]# mkdir test01
[root@linuxprobe test]# ll -d test01/
drwxr-xr-x. 2 root root 6 Oct 21 14:09 test01/
[root@linuxprobe test]# chmod 770 test01/ ## 將其他人的許可權設定為0
[root@linuxprobe test]# ll -d test01/
drwxrwx---. 2 root root 6 Oct 21 14:09 test01/
[root@linuxprobe test]# su - linuxprobe ## 切換至普通使用者
Last login: Wed Oct 21 13:15:32 CST 2020 from 192.168.3.4 on pts/2
[linuxprobe@linuxprobe ~]$ cd /home/test/
[linuxprobe@linuxprobe test]$ whoami
linuxprobe
[linuxprobe@linuxprobe test]$ ls
test01
[linuxprobe@linuxprobe test]$ cd test01 / ## 其他人沒有訪問的許可權
-bash: cd: test01/: Permission denied
[linuxprobe@linuxprobe test]$ su - liujiaxin01 ## 切換至另一個普通使用者
Password:
Last login: Wed Oct 21 13:01:47 CST 2020 from 192.168.3.4 on pts/1
[liujiaxin01@linuxprobe ~]$ cd /home/test/
[liujiaxin01@linuxprobe test]$ ls
test01
[liujiaxin01@linuxprobe test]$ whoami
liujiaxin01
[liujiaxin01@linuxprobe test]$ cd test01 / ## 仍然沒有訪問許可權
-bash: cd: test01/: Permission denied
## 測試給linuxprobe分配許可權,未給liujiaxin01分配許可權的情況
[liujiaxin01@linuxprobe test]$ exit
logout
[linuxprobe@linuxprobe test]$ exit
logout
[root@linuxprobe test]# whoami
root
[root@linuxprobe test]# ls
test01
[root@linuxprobe test]# setfacl u:linuxprobe:rwx test01/
Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...
Try `setfacl --help' for more information.
[root@linuxprobe test]# setfacl -R u:linuxprobe:rwx test01/
Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...
Try `setfacl --help' for more information.
[root@linuxprobe test]# setfacl -Rm u:linuxprobe:rwx test01/
## 針對目錄設定ACL的基本用法,-R 表示遞迴 ,-m modify?,u指的是user,linuxprobe指使用者,rwx指賦予使用者的許可權
## 上句命令的意思就是賦予給linuxprobe使用者針對目錄test01的讀、寫、執行的許可權
[root@linuxprobe test]# su - linuxprobe ## 切換至linuxProbe ,檢視許可權設定效果
Last login: Wed Oct 21 14:10:45 CST 2020 on pts/0
[linuxprobe@linuxprobe ~]$ cd /home/test/
[linuxprobe@linuxprobe test]$ whoami
linuxprobe
[linuxprobe@linuxprobe test]$ ls
test01
[linuxprobe@linuxprobe test]$ cd test01/ ## 設定後可以正常訪問了
[linuxprobe@linuxprobe test01]$ su - liujiaxin01 ## 為了對比,切換至另一普通使用者
Password:
Last login: Wed Oct 21 14:13:00 CST 2020 on pts/0
[liujiaxin01@linuxprobe ~]$ cd /home/test/
[liujiaxin01@linuxprobe test]$ whoami
liujiaxin01
[liujiaxin01@linuxprobe test]$ ls
test01
[liujiaxin01@linuxprobe test]$ cd test01/ ## 不能正常訪問
-bash: cd: test01/: Permission denied