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

Unix 檔案權限:目錄權限與 chmod 符號模式

檔案權限是 Unix 安全性的第一道防線。讀取、寫入與執行是三種基本權限。

  • 讀取:可查看檔案內容。
  • 寫入:可修改或刪除內容。
  • 執行:可將檔案當作程式執行。

目錄權限

目錄也有讀取、寫入與執行權限,但含義略有不同:

  • 讀取:可列出目錄中的名稱。
  • 寫入:可在目錄中新增或刪除項目。
  • 執行:可進入或遍歷目錄。

使用 chmod 符號模式

chmod 可用符號調整權限:

  • +:新增權限。
  • -:移除權限。
  • =:設定指定權限。
ls -l testfile
-rwxrwxr-- 1 amrood users 1024 Nov 2 00:10 testfile

chmod o+wx testfile
ls -l testfile
-rwxrwxrwx 1 amrood users 1024 Nov 2 00:10 testfile

chmod u-x testfile
ls -l testfile
-rw-rwxrwx 1 amrood users 1024 Nov 2 00:10 testfile

chmod g=rx testfile
ls -l testfile
-rw-r-xrwx 1 amrood users 1024 Nov 2 00:10 testfile

也可將多個設定合併在同一行:

chmod o+wx,u-x,g=rx testfile
Copyright © Linux教程網 All Rights Reserved