setfacl -m d:u:zym:rwx /dir1
==當對目錄/dir1 設定了預設權限,之後在該目錄下建立的所有
檔案,jack 預設擁有 rwx 權限
==注意:rwx 權限不針對該目錄,也不針對該目錄中現有的檔案
zym@zym-TOP2:~$ sudo mkdir /dir1/{test1,test2} -p
zym@zym-TOP2:~$ ll -d /dir1/
drwxr-xr-x 4 root root 4096 2月 15 16:31 /dir1//
zym@zym-TOP2:~$ ll /dir1/
總用量 16
drwxr-xr-x 4 root root 4096 2月 15 16:31 ./
drwxr-xr-x 24 root root 4096 2月 15 16:31 ../
drwxr-xr-x 2 root root 4096 2月 15 16:31 test1/
drwxr-xr-x 2 root root 4096 2月 15 16:31 test2/
zym@zym-TOP2:~$
zym@zym-TOP2:~$ sudo setfacl -m d:u:zym:rwx /dir1/
zym@zym-TOP2:~$ getfacl /dir1/
getfacl: 從絕對路徑名尾部去除" / "字元。
# file: dir1/
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:zym:rwx
default:group::r-x
default:mask::rwx
default:other::r-x
zym@zym-TOP2:~$ touch /dir1/file1
touch: 無法建立"/dir1/file1": 權限不夠
zym@zym-TOP2:~$ touch /dir1/test1/file1
touch: 無法建立"/dir1/test1/file1": 權限不夠
zym@zym-TOP2:~$ sudo mkdir /dir1/test3
zym@zym-TOP2:~$ sudo touch /dir1/file1
drwxr-xr-x+ 5 root root 4096 2月 15 16:37 /dir1//
總用量 20
drwxr-xr-x+ 5 root root 4096 2月 15 16:37 ./
drwxr-xr-x 24 root root 4096 2月 15 16:31 ../
-rw-rw-r--+ 1 root root 0 2月 15 16:37 file1
drwxr-xr-x 2 root root 4096 2月 15 16:31 test1/
drwxr-xr-x 2 root root 4096 2月 15 16:31 test2/
drwxrwxr-x+ 2 root root 4096 2月 15 16:36 test3/
zym@zym-TOP2:~$ sudo touch /dir1/test3/file1
zym@zym-TOP2:~$ echo "test" > /dir1/file1
zym@zym-TOP2:~$ getfacl /dir1/test3/
# file: dir1/test3/
user:zym:rwx
mask::rwx
MASK
其作用是為了用來限制除了屬主和其他人以外的所有使用者或組
的權限,MASK 權限則為這些使用者他們可能擁有的最高權限;
如果遇到設定的使用者權限和 MASK 權限沖突,則使用者的權限為
#effective 權限
一旦一個檔案被設定了 ACL,其檔案原屬組部分的權限将變為
MASK 權限,而并非原來的屬組權限;
setfacl -m m::r dir|file
setfacl -m mask::r dir|file
zym@zym-TOP2:~$ sudo setfacl -m mask::r /dir4/
zym@zym-TOP2:~$ getfacl /dir4/
# file: dir4/
group::r-x #effective:r--
mask::r--
由于設定了 ACL,并更改了 mask 權限:setfacl -m m::r /dir4
==ll -d /dir4 所看到的屬組權限部分為 mask 權限
==雖然使用者 zym 設定了 rwx 權限,但他的有效權限為 r
本文轉自zhang25yun51CTO部落格,原文連結:http://blog.51cto.com/1585654/1359417 ,如需轉載請自行聯系原作者