setfacl設定特定目錄的許可權

2022-08-31 09:12:08 字數 2184 閱讀 2564

現有一目錄是虛擬機器和linux共享的,但是每次程式呼叫新建的檔案都發現沒有許可權。

於是指定特定目錄及其子目錄下新建的檔案或目錄對於使用者qhfz都有讀寫執行的許可權

-r表示遞迴 -m表示設定檔案acl規則

setfacl -r -m d:u:qhfz:rwx /data2/resourcecase

setfacl -r -m d:u: resourcecase:rwx /data2/resourcecase

--刪除acl規則使用-b

setfacl -r -b /data2/resourcecase

上面的d:u:詳見如下,而perms對應的是rwx:

setfacl命令可以識別以下的規則格式。

[d[efault]:][u[ser]:]uid[:perms]

指定使用者的許可權,檔案所有者的許可權(如果uid沒有指定)。

[d[efault]:]g[roup]:gid[:perms]

指定群組的許可權,檔案所有群組的許可權(如果gid未指定)

[d[efault]:]m[ask][:][:perms]

有效許可權掩碼

[d[efault]:]o[ther][:perms]

#perms域是乙個代表各種許可權的字母的組合:讀:r 寫:w 執行:x,執行只適合目錄和一些可執行的檔案。perms域也可設定為八進位制格式0~7。

#其他的許可權

usage:setfacl[-bkndrlp]file... # -m|-m|-x|-x

-m,--modify=acl modify the current acl(s)of file(s) #設定檔案acl規則

-m,--modify-file=file read acl entries to modify from file #從檔案讀取訪問控制列表條目更改

-x,--remove=acl remove entries from the acl(s)of file(s) #刪除檔案的acl規則

-x,--remove-file=file readacl entries to remove from file #從檔案讀取訪問控制列表條目並刪除

-b,--remove-all remove all extended acl entries # 刪除所有擴充套件的acl規則,基本的acl規則(所有者,群組,其他)將被保留.

-k,--remove-default remove the defaultacl #刪除預設的acl規則。如果沒有預設規則,將不提示.

--set=acl set the acl of file(s),replacing the current acl.

--set-file=file readacl entries toset from file #從檔案中讀設定acl規則.

--mask dorecalculate the effective rights mask #重新計算有效許可權,即使acl mask被明確指定.

-n,--no-mask don'trecalculate the effective rights mask #不要重新計算有效許可權。setfacl缺省會重新計算acl mask,除非mask被明確的制定.

-r,--recursive recurse into subdirectories #遞迴的對所有檔案及目錄進行操作.

-l,--logical logical walk,follow symbolic links #跟蹤符號鏈結,預設情況下只跟蹤符號鏈結檔案,跳過符號鏈結目錄。

-p,--physical physical walk,donotfollow symbolic links #跳過所有符號鏈結,包括符號鏈結檔案。

--restore=file restore acls(inverse of`getfacl-r') #從檔案恢復備份的acl規則(這些檔案可由getfacl -r產生)。通過這種機制可以恢復整個目錄樹的acl規則。此引數不能和除--test以外的任何引數一同執行.

--test testmode(acls are notmodified) #測試模式,不會改變任何檔案的acl規則,操作後的acl規格將被列出.

-v,--version print version andexit #版本.

-h,--help thishelp text #不用說肯定是幫助了.

當使用-m,-x選項從檔案中讀取規則時,setfacl接受getfacl命令輸出的格式。每行至少一條規則,以#開始的行將被視為注釋.

setfacl 設定特定目錄的許可權Linux

建立使用者 useradd readonly 刪除使用者 userdel readonly 修改密碼 passwd readonly 新增使用者對檔案的唯讀r許可權 setfacl m u readonly r data software 刪除使用者對檔案的許可權 setfacl x user re...

設定或清除特定的位

嵌入式系統總是要求使用者對變數或暫存器進行位操作。給定乙個整型變數a,寫兩段 第乙個設定a的bit 3,第二個清除a的bit 3.在以上兩個操作中,要保持其它位不變。1 不知道如何下手,表示自己從沒做過任何嵌入式系統的工作 2 用bit fields。bit fields是被扔到c語言死角的東西,它...

關於雙網絡卡電腦,特定網頁走特定網絡卡的設定

雙網絡卡有時候因為訪問順序原因導致不能訪問某些特定網頁,下面介紹一下我解決此類問題的方法 開啟網路共享中心,在左側中間 下面主要介紹換網絡卡就可以進去的方法 1 可用網絡卡進去後 開啟cmd,輸入 ping 空格 網域名稱 網域名稱為中間那個,如www.baidu.com 網域名稱為baidu pi...