Red Hat Linux 7 下 ACL許可權基本設定

來源:互聯網
上載者:User

Red Hat Linux 7 下 ACL許可權基本設定

一 ACL簡介:

存取控制清單(Access Control List,ACL) 是路由器和交換器介面的指令列表,用來控制連接埠進出的資料包。ACL適用於所有的被路由協議,如IP、IPX、AppleTalk等。

二  如何查看許可權列表:

[bkjia@foundation2 Desktop]$    ls  -l  file
-rw-rw-r--      .      1 root kiosk 0 Nov  7 09:19 file
如果此位為  “.”  代表這位沒有許可權列表
如果此為      “+”  代表有許可權列表存在

那麼我們首先給 file 檔案加上許可權列表

 並且通過 ll 命令發現已經有了許可權列表
 則可以通過 getfacl  命令查看更加詳細的許可權

[root@localhost Desktop]# setfacl -m u:student:rwx file
[root@localhost Desktop]# ll
total 4
-rw-rwxr--+ 1 root root 0 Nov 9 11:11 file
[root@localhost Desktop]# getfa
getfacl getfattr
[root@localhost Desktop]# getfacl file
# file: file
# owner: root
# group: root
user::rw-
user:student:rwx
group::r--
mask::rwx
other::r--

那麼這些分別代表什麼呢
[root@localhost Desktop]$ getfacl  file
# file: file        檔案名稱
# owner: root      檔案所有人
# group: kiosk      檔案所有組
user::rw-            檔案使用者權限
user:student:rwx    檔案特定使用者權限
group::rw-          所有組許可權
mask::rwx          特定使用者生效的最大許可權
other::r--            其他人許可權

三 如何設定  acl  許可權

由 有設定方式,故下面是我的一些設定方式的總結

setfacl          -m            <u|g|m>:<username|groupname>:許可權  filename    acl設定方式

setfacl        -b              filname      刪除檔案許可權列表,一下子就全刪了,+號都沒有了
setfacl        -x                <u|g>:<username|groupname>  filename    刪除特定許可權的特定使用者或組

四  acl 預設許可權
預設許可權之針對目錄使用,是讓目錄中所有建立檔案都繼承此許可權

setfacl -m d:<u|g|o>:<username|group>:rwx    directory 
設定預設許可權,這個許可權對目錄本身不生效,只對裡面內容生效(建立的)

[root@localhost /]# mkdir /xp
[root@localhost /]# setfacl -m d:u:student:rwx /xp
[root@localhost /]# getfacl /xp
getfacl: Removing leading '/' from absolute path names
# file: xp
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:student:rwx
default:group::r-x
default:mask::rwx
default:other::r-x
[root@localhost xp]# touch file
[root@localhost xp]# ll
total 4
-rw-rw-r--+ 1 root root 0 Nov 9 15:25 file
[root@localhost xp]# cat file
[root@localhost xp]#
由上面可知道other對於它只有r許可權
那麼接下來我們用student 使用者試試有沒有剛才設定的許可權(切記,許可權加了之後才建立的file)

[root@localhost xp]# su - student
Last login: Mon Nov 9 15:24:51 EST 2015 on pts/0
[student@localhost ~]$ cd /xp
[student@localhost xp]$ echo hello,world >file
[student@localhost xp]$ cat file
hello,world
顯然已經成功,不過只是對建立的檔案產生作用,以前存在的不受影響。

setfacl  -x d:<u|g|o>:<username|group>  directory
撤銷目錄中某條預設許可權

setfacl -b  directory
刪除檔案許可權列表

[root@localhost xp]# setfacl -x d:u:student file
[root@localhost xp]# getfacl file
# file: file
# owner: root
# group: root
user::rw-
user:student:rwx #effective:rw-
group::r-x #effective:r--
mask::rw-
other::r--

[root@localhost xp]# setfacl -b file
[root@localhost xp]# ll
total 4
-rw-r--r--. 1 root root 12 Nov 9 15:30 file

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.