Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> Unix基礎知識

Unix 檔案權限設定:chmod 絕對權限

chmod 除了可用符號模式修改權限,也能用數字指定權限。每個權限都有固定數值,將三組權限相加即可得到三位八進位數字。

  • 0:無權限
  • 1:可執行
  • 2:可寫入
  • 3:可執行與寫入
  • 4:可讀取
  • 5:可讀取與執行
  • 6:可讀取與寫入
  • 7:可讀取、寫入與執行

以 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

第一個數字代表擁有者,第二個數字代表同組使用者,第三個數字代表其他人。熟悉數字對應後,就能快速設定檔案存取權限。

Copyright © Linux教程網 All Rights Reserved