chmod

Linux chmod指令 語法

作用:利用 chmod 可以藉以控制文件如何被他人所調(diào)用。

權(quán)限:所有使用者

語法:chmod [-cfvR] [--help] [--version] mode file...

Linux chmod指令 範(fàn)例

將檔案file1.txt 設(shè)為所有人皆可讀取:

chmod ugo+r file1.txt

將檔案file1.txt 設(shè)為所有人皆可讀取:

chmod a+r file1.txt

將檔案file1.txt與file2.txt 設(shè)為該檔案擁有者,與其所屬同一個(gè)群體者可寫入,但其他以外的人則不可寫入:

chmod ug+w,o-w file1.txt file2.txt

將ex1.py 設(shè)定為只有該檔案擁有者可以執(zhí)行:

chmod u+x ex1.py

將目前目錄下的所有檔案與子目錄皆設(shè)為任何人可讀取:

chmod -R a+r *

此外chmod也可以用數(shù)字來表示權(quán)限如:

chmod 777 file

語法為:

chmod abc file