chmod 除了可用符號模式修改權限,也能用數字指定權限。每個權限都有固定數值,將三組權限相加即可得到三位八進位數字。
以 testfile 為例,先查看目前權限:
ls -l testfile -rwxrwxr-- 1 amrood users 1024 Nov 2 00:10 testfile
接著套用不同數字模式:
chmod 755 testfile ls -l testfile -rwxr-xr-x 1 amrood users 1024 Nov 2 00:10 testfile chmod 743 testfile ls -l testfile -rwxr---wx 1 amrood users 1024 Nov 2 00:10 testfile chmod 043 testfile ls -l testfile ----r---wx 1 amrood users 1024 Nov 2 00:10 testfile
第一個數字代表擁有者,第二個數字代表同組使用者,第三個數字代表其他人。熟悉數字對應後,就能快速設定檔案存取權限。