Linux setfacl/getfacl命令詳解


setfacl,命令名,設置文件訪問控制列表,即ACL規則。而Acl(Access Control List)就是訪問控制列表

setfacl常見命令參數

setfacl 2.2.51 -- 設定文件訪問控制列表

用法: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...
  -m, --modify=acl 更改文件的訪問控制列表
  -M, --modify-file=file 從文件讀取訪問控制列表條目更改
  -x, --remove=acl 根據文件中訪問控制列表移除條目
  -X, --remove-file=file 從文件讀取訪問控制列表條目並刪除
  -b, --remove-all 刪除所有擴展訪問控制列表條目
  -k, --remove-default 移除默認訪問控制列表
      --set=acl 設定替換當前的文件訪問控制列表
      --set-file=file 從文件中讀取訪問控制列表條目設定
      --mask 重新計算有效權限掩碼
  -n, --no-mask 不重新計算有效權限掩碼
  -d, --default 應用到默認訪問控制列表的操作
  -R, --recursive 遞歸操作子目錄
  -L, --logical 依照系統邏輯,跟隨符號鏈接
  -P, --physical 依照自然邏輯,不跟隨符號鏈接
      --restore=file 恢復訪問控制列表,和“getfacl -R”作用相反
      --test 測試模式,並不真正修改訪問控制列表屬性
  -v, --version           顯示版本並退出
  -h, --help              顯示本幫助信息

getfacl常見命令參數

getfacl 2.2.49 -- get file access control lists
Usage: getfacl [-aceEsRLPtpndvh] file ...
  -a,  --access           display the file access control list only
  -d, --default           display the default access control list only
  -c, --omit-header       do not display the comment header
  -e, --all-effective     print all effective rights
  -E, --no-effective      print no effective rights
  -s, --skip-base         skip files that only have the base entries
  -R, --recursive         recurse into subdirectories
  -L, --logical           logical walk, follow symbolic links
  -P, --physical          physical walk, do not follow symbolic links
  -t, --tabular           use tabular output format
  -n, --numeric           print numeric user/group identifiers
  -p, --absolute-names    don't strip leading '/' in pathnames
  -v, --version           print version and exit
  -h, --help              this help text

常用的命令展示

獲取文件的ACL

[root@localhost omc]# touch hhh
[root@localhost omc]# getfacl hhh

image

更改文件的ACL,添加一個用戶的權限

[root@localhost ~]#   setfacl -m u:omc:rwx hhh
[root@localhost ~]#  setfacl -m g:omc:r-w test      #添加一個組[root@localhost ~]#  getfacl hhh

image

【更多參考】http://linux.51yip.com/search/setfacl


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM