Linux命令溫故而知新:chmod

來源:互聯網
上載者:User

chmod:改變檔案許可權

符號模式:

chmod命令的一般格式為:
chmod [who] operator [permission] filename

who的含義是:
u  檔案的屬主許可權
g  同組使用者的許可權
o  其他使用者權限
a  所有使用者(檔案屬主、同組使用者及其他使用者)

operator的含義:
+ 增加許可權
- 取消許可權
= 設定許可權

permission的含義:
r 讀許可權
w 寫入權限
x 執行許可權
s 檔案屬主和級set-ID
t 粘性位*
l 給檔案加鎖,使其他使用者無法訪問

eg:
chmod a-x file.txt   收回所有使用者的執行許可權
chmod og-w file.txt  收回同組和其他使用者的寫入權限
chmod g+w file.txt 賦予同組使用者寫入權限
chmod u+x file.txt  賦予檔案屬主執行許可權
chmod go+x  file.txt  賦予同組使用者和其他使用者執行許可權

絕對模式
chmod命令絕對模式一般形式為
chmod [mode] file
其中mode是一個八位元

eg:
chmod 666   賦予所有使用者讀和寫入權限
chmod 644 賦予所有檔案屬主讀和寫入權限,所有其它使用者讀許可權
chmod 700  賦予檔案屬主讀、寫和執行的許可權,其它使用者沒有任何許可權

其中-R參數可以遞迴設定包括目錄在內的所有檔案的許可權。
eg:
chmod -R 744 /usr/local/home/

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.