標籤:reference linux file 使用者
1 chmod:修改檔案及目錄許可權
選項:--reference=file 根據參考檔案設定許可權
-R 遞迴設定許可權
chmod命令參數中,u代表所有者,g代表屬組,o代表其它使用者,a代表所有人
[[email protected] ~]# chmod 755 a.txt
[[email protected] ~]# chmod o-x a.txt
[[email protected] ~]# chmod u=rw,g=rw,o=r a.txt
[[email protected] ~]# chmod --reference=install.log a.txt
[[email protected] /]# chmod -R 644 /c
2 chown:改變檔案或目錄的所有者和所屬組
選項:-R:遞迴改變
--reference=RFILE:按照模板檔案修改屬主和屬組
[[email protected] ~]# chown zwj a.txt #修改屬主
[[email protected] ~]# chown :zwj a.txt #修改屬組
[[email protected] ~]# chown root.root a.txt #修改屬主和屬組
[[email protected] ~]# chown --reference=a.sh a.txt
3 ACL存取控制許可權:針對單獨的使用者佈建文檔的存取權限
3.1 查看檔案的ACL許可權
[[email protected] ~]# getfacl a.txt
# file: a.txt #檔案名稱
# owner: root #檔案屬主
# group: root #檔案屬組
user::rw- #檔案所有者許可權
group::rw- #檔案屬組許可權
other::r-- #其它使用者權限
3.2 設定檔案存取控制清單
用法:setfacl [選項] [{-m|-x} acl條目] 檔案或目錄
選項:-b 刪除所有條目
-m 添加ACL條目
-x 刪除指定ACL條目
-R 遞迴處理所有子目錄和子檔案
[[email protected] ~]# setfacl -m u:abc:rw a.txt
#添加ACL條目,使使用者abc對檔案a.txt有讀寫的許可權
[[email protected] ~]# setfacl -x u:abc a.txt
#刪除abc賬戶的ACL許可權
[[email protected] ~]# setfacl -m g:abc:rwx a.txt
#添加ACL條目,使組abc對a.txt可以讀寫執行
[[email protected] ~]# setfacl -b a.txt
#刪除所有附加的ACL許可權
本文出自 “一萬年太久,只爭朝夕” 部落格,請務必保留此出處http://zengwj1949.blog.51cto.com/10747365/1916794
Linux命令之檔案及目錄許可權