centos文件系統訪問控制列表

FACL:filesystem access control list
利用文件的擴展屬性,保存了額外的訪問控制權限

getfacl 查看
setfacl 設置

語法:setfacl [-bkRd]  [-m|-x acl 參數]  目標文件名

選項與參數:

-m:設置後續的acl參數,不可與-x一起使用

-x: 刪除後續的acl參數,不可與-m一起使用

-b:刪除所有的acl參數

-k:刪除默認的acl參數

-R:遞歸設置acl參數

-d:設置默認acl參數,只對目錄有效

setfacl -m m:rw inittab

    -m設定,可以設定到用戶或者是組上
        u:uid:perm
        g:gid:perm
        例子:
        #mkdir /backup
        #cd /backup
        #cp /etc/inittab ./
        #getfacl inittab
        #setfacl -m u:redhat:rw inittab
    owner>facl,user> group > facl group>

    所有權限都不能超過mask的權限
    setfacl -m m:rwx [filename or directory_name]
    -x取消
        setfacl -x u:uid file_name
    爲目錄設定默認訪問控制列表:
        d:u:uid:perm file_name

        mount -o acl /dev/myvg1/mylv1 /mnt 
        dumpe2fs -h /dev/myvg1/mylv1(查看是否支持ACL)
        tune2fs -o 

例子: 授權一個用戶讀權限
setfacl -m u:lisa:r file

   Revoking  write  access  from  all  groups and all named users (using the
   effective rights mask)
   撤銷所有的組和用戶的寫權限(使用有效的正確mask)
          setfacl -m m::rx file

   Removing a named group entry from a file’s ACL
   移除一個組的ACL權限
          setfacl -x g:staff file

   Copying the ACL of one file to another
   複製一個文件的ACL到另一個文件
          getfacl file1 | setfacl --set-file=- file2

   Copying the access ACL into the Default ACL
   複製訪問的目錄的ACL作爲目錄的默認ACL
          getfacl --access dir | setfacl -d -M- dir     
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章