如何用chmod設定檔案許可權

2021-10-07 05:42:21 字數 822 閱讀 4003

unix中的檔案和目錄可能具有三種許可權:讀取(`r「),寫入(`w')和執行(`x')。 對於以下三種類別的使用者,每個許可可以是「開啟」或「關閉」:檔案或目錄所有者; 與所有者在同一組中的其他人; 和所有其他。

1.檔案

要更改檔案的模式,請使用chmod命令。 一般形式是

chmod x @ y file1 file2 ...

其中:x是字母「 u」(對於所有者),「 g」(對於組),「 o」(對於其他人),「 a」(對於所有;即對於「 ugo」)的任意組合; @是新增許可權的「 +」,刪除許可權的「-」或絕對分配許可權的「 =」; y是`r',`w',`x'的任意組合。 以下是一些示例:

chmod u=rx file        (give the owner rx permissions, not w)

chmod go-rwx file (deny rwx permission for group, others)

chmod g+w file (give write permission to the group)

chmod a+x file1 file2 (give execute permission to everybody)

chmod g+rx,o+x file (ok to combine like this with a comma)

2.目錄

上述許可方案也適用於目錄。 對於目錄,具有「讀取」許可權的任何人都可以使用ls命令列出檔案(從而發現其中有哪些檔案); 擁有「寫」許可權的人可以在該目錄中建立和刪除檔案; 具有執行許可權的任何人都可以訪問已知名稱的檔案或子目錄。

chmod 設定檔案特殊許可權

linux中除了常見的讀 r 寫 w 執行 x 許可權以外,還有3個特殊的許可權,分別是setuid setgid和stick bit 1 setuid setgid 先看個例項,檢視你的 usr bin passwd 與 etc passwd檔案的許可權 root mylinux ls l usr...

chmod 許可權設定

1修改許可權 命令 chmod change mode 功能 改變檔案的讀寫和執行許可權。有符號法和八進位制數字法。選項 1 符號法 命令格式 chmod filename u user 表示使用者本人。g group 表示同組使用者。o oher 表示其他使用者。a all 表示所有使用者。用於給...

chmod許可權設定

drwxr xr x.7 root root 4096 sep 26 20 16 sysconfig rw r r 1 root root 1150 aug 31 18 46 sysctl.conf lrwxrwxrwx.1 root root 14 aug 31 17 21 system rele...