Linux命令之檔案及目錄許可權

來源:互聯網
上載者:User

標籤: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命令之檔案及目錄許可權

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.