主頁(yè) > 知識(shí)庫(kù) > CentOS下ACL權(quán)限控制詳解

CentOS下ACL權(quán)限控制詳解

熱門(mén)標(biāo)簽:太原外呼電銷(xiāo)機(jī)器人軟件 廣州點(diǎn)撥外呼系統(tǒng)多少錢(qián)一個(gè)月 電話外呼系統(tǒng)解決方案 400外呼系統(tǒng) 配置要求 仙桃外呼系統(tǒng) 怎樣在北斗地圖標(biāo)注商戶 辦理400電話的好處都有哪些 貴港便宜外呼系統(tǒng)報(bào)價(jià) 日立hgp外呼線路圖

ACL權(quán)限控制

設(shè)置ACL權(quán)限:setfacl

查看ACL權(quán)限:getfacl

ACL權(quán)限控制主要目的是提供傳統(tǒng)的owner,group,other的read,wirte,execute權(quán)限之外的具體權(quán)限設(shè)置,可以針對(duì)單一用戶或組來(lái)設(shè)置特定的權(quán)限

比如:某一目錄權(quán)限為

drwx------ 2 root root 4096 03-10 13:51./acldir

用戶user對(duì)此目錄無(wú)任何權(quán)限因此無(wú)法進(jìn)入此目錄,ACL可單獨(dú)為用戶user設(shè)置這個(gè)目錄的權(quán)限,使其可以操作這個(gè)目錄

ACL啟動(dòng)

要使用ACL必須要有文件系統(tǒng)支持才行,目前絕大多數(shù)的文件系統(tǒng)都會(huì)支持,EXT3文件系統(tǒng)默認(rèn)啟動(dòng)ACL的

查看文件系統(tǒng)是否支持ACL

[root@localhost tmp]#

dumpe2fs -h /dev/sda2 dumpe2fs 1.39 (29-May-2006)

……

sparse_super large_file

Default mount options: user_xattr acl

加載ACL功能

如果UNIX LIKE支持ACL但是文件系統(tǒng)并不是默認(rèn)加載此功能,可自己進(jìn)行添加

[root@localhost tmp]# mount -o remount,acl /

[root@localhost tmp]# mount

/dev/sda2 on / type ext3 (rw,acl)

同樣也可以修改磁盤(pán)掛在配置文件設(shè)置默認(rèn)開(kāi)機(jī)加載

[root@localhost tmp]# vi /etc/fstab

LABEL=/ / ext3 defaults,acl 1 1

查看ACL權(quán)限

語(yǔ)法:getfacl filename

設(shè)置ACL權(quán)限

語(yǔ)法:setfacl [-bkRd]  [-m|-x acl 參數(shù)]  目標(biāo)文件名

選項(xiàng)與參數(shù):

-m:設(shè)置后續(xù)的acl參數(shù),不可與-x一起使用

-x: 刪除后續(xù)的acl參數(shù),不可與-m一起使用

-b:刪除所有的acl參數(shù)

-k:刪除默認(rèn)的acl參數(shù)

-R:遞歸設(shè)置acl參數(shù)

-d:設(shè)置默認(rèn)acl參數(shù),只對(duì)目錄有效

針對(duì)特殊用戶

設(shè)置格式:u:用戶賬號(hào)列表:權(quán)限

權(quán)限:rwx的組合形式

如用戶列表為空,代表設(shè)置當(dāng)前文件所有者權(quán)限

舉例:

[root@localhost tmp]# mkdir -m 700 ./acldir; ll -d ./acldir

drwx------ 2 root root 4096 03-10 13:51 ./acldir

[root@localhost tmp]# su tkf

[tkf@localhost tmp]$ cd ./acldir/

bash: cd: ./acldir/: 權(quán)限不夠 =>用戶無(wú)X權(quán)限

[tkf@localhost tmp]$ exit

exit

[root@localhost tmp]# setfacl -m u:tkf:x ./acldir/

=>針對(duì)用戶tkf設(shè)置acldir目錄的權(quán)限為x

[root@localhost tmp]# ll -d ./acldir/

drwx--x---+ 2 root root 4096 03-10 13:51 ./acldir/

=>通過(guò)ACL添加權(quán)限在權(quán)限末尾會(huì)增加多個(gè)一個(gè)“+”同時(shí)文件原本權(quán)限也發(fā)生變化。

=>可通過(guò)getfacl查看原始目錄權(quán)限

[root@localhost tmp]# getfacl ./acldir/

# file: acldir

# owner: root

# group: root

user::rwx

user:tkf:--x =>記錄tkf用戶針對(duì)此目錄有acl權(quán)限

group::---

mask::--x

other::---

=>這里需要特殊說(shuō)明,只是tkf這個(gè)用戶具有X權(quán)限,其他用戶還是無(wú)權(quán)限的

[root@localhost tmp]# su tkf

[tkf@localhost tmp]$ cd ./acldir/

[tkf@localhost acldir]$

=>用戶tkf可以具有x權(quán)限可以進(jìn)入目錄

針對(duì)特定用戶組

設(shè)置格式:g:用戶組列表:權(quán)限

權(quán)限:rwx的組合形式

如用戶組列表為空,代表設(shè)置當(dāng)前文件所屬用戶組權(quán)限

舉例:

[root@localhost tmp]# setfa

setfacl setfattr

[root@localhost tmp]# setfacl -m g:users:rx ./acldir/

[root@localhost tmp]# getfacl ./acldir/

# file: acldir

# owner: root

# group: root

user::rwx

user:tkf:--x

group::--- => 其他用戶組(非acl設(shè)置)的權(quán)限

group:users:r-x => 記錄users用戶組針對(duì)此目錄有acl權(quán)限

mask::r-x

other::---

針對(duì)有效權(quán)限設(shè)置

有效權(quán)限(mask)就是acl權(quán)限設(shè)置的極限值,也就是你所設(shè)置的acl權(quán)限一定是mask的一個(gè)子集,如果超出mask范圍會(huì)將超出的權(quán)限去掉

設(shè)置格式:m:權(quán)限

權(quán)限:rwx的組合形式

舉例:

[root@localhost tmp]# setfacl -m m:x ./acldir/

[root@localhost tmp]# getfacl ./acldir/

# file: acldir

# owner: root

# group: root

user::rwx

user:tkf:--x

group::r-x #effective:--x

group:users:r-x #effective:--x

mask::--x

other::---

針對(duì)默認(rèn)權(quán)限設(shè)置

我們前面都是針對(duì)一個(gè)目錄為一個(gè)用戶(組)設(shè)置特定權(quán)限,但是如果這個(gè)目錄下在新創(chuàng)建的文件是不具有這些針對(duì)這個(gè)用戶的特定權(quán)限的。為了解決這個(gè)問(wèn)題,就需要設(shè)置默認(rèn)acl權(quán)限,使這個(gè)目錄下新創(chuàng)建的文件有和目錄相同的ACL特定權(quán)限

設(shè)置格式:d:[u|g]:用戶(組)列表:權(quán)限

舉例

[root@localhost tmp]# mkdir -m 711 ./defdir

[root@localhost tmp]# setfacl -m u:tkf:rxw ./defdir

[root@localhost tmp]# ll -d ./defdir/

drwxrwx--x+ 2 root root 4096 03-10 15:23 ./defdir/

=>目錄權(quán)限具有acl特定權(quán)限(后面+)

[root@localhost tmp]# touch ./defdir/a.file;ll ./defdir/

-rw-r--r-- 1 root root 0 03-10 15:25 a.file

=>新創(chuàng)建的文件不具有acl特定權(quán)限(后面無(wú)+)

[root@localhost tmp]# setfacl -m d:u:tkf:rxw ./defdir

=>設(shè)置默認(rèn)權(quán)限

[root@localhost tmp]

# getfacl ./defdir/

# file: defdir

# owner: root

# group: root

user::rwx

user:tkf:rwx

group::--x

mask::rwx

other::--x

default:user::rwx

default:user:tkf:rwx

default:group::--x

default:mask::rwx

default:other::--x

[root@localhost tmp]# touch ./defdir/b.file;ll ./defdir/

-rw-r--r-- 1 root root 0 03-10 15:25 a.file

-rw-rw----+ 1 root root 0 03-10 15:26 b.file

=>新創(chuàng)建文件默認(rèn)帶有acl特定權(quán)限

[root@localhost tmp]

# getfacl ./defdir/b.file

# file: defdir/b.file

# owner: root

# group: root

user::rw- user:tkf:rwx #effective:rw-

group::--x #effective:---

mask::rw-

other::---

=>這快我有個(gè)疑問(wèn),為什么mask值是rw,我猜測(cè)和文件最大權(quán)限有關(guān),

=>對(duì)于文件來(lái)時(shí)默認(rèn)最大權(quán)限是666即UMASK為0000.那個(gè)對(duì)于可執(zhí)行文件來(lái)說(shuō)

=>沒(méi)有X,難道還需要使用chmod設(shè)置? 疑問(wèn)??!

標(biāo)簽:廣安 河源 青島 商丘 公主嶺 麗水 六盤(pán)水 雅安

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《CentOS下ACL權(quán)限控制詳解》,本文關(guān)鍵詞  CentOS,下,ACL,權(quán)限,控制,詳解,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《CentOS下ACL權(quán)限控制詳解》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于CentOS下ACL權(quán)限控制詳解的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章