Linux chmod命令詳解


    chmod命令用於改變linux系統文件或目錄的訪問權限。html

該命令有兩種用法:linux

一種是包含字母和操做符表達式的文字設定法;shell

另外一種是包含數字的數字設定法。post

文件或目錄的訪問權限分爲只讀,只寫和可執行三種。ui

chmod常見命令參數

Usage: chmod [OPTION]... MODE[,MODE]... FILE...
  or:  chmod [OPTION]... OCTAL-MODE FILE...
  or:  chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.

  -c, --changes           like verbose but report only when a change is made
      --no-preserve-root  do not treat `/' specially (the default)
      --preserve-root     fail to operate recursively on `/'
  -f, --silent, --quiet   suppress most error messages
  -v, --verbose           output a diagnostic for every file processed
      --reference=RFILE   use RFILE's mode instead of MODE values
  -R, --recursive         change files and directories recursively
      --help     display this help and exit
      --version  output version information and exit

經常使用的命令展現

421 分別表明文件的讀、寫、執行的權限this

chmod:更改屬性值的
chmod 755 -R / 系統默認臨界     【002:系統的默認掩碼】
chmod 644 /     系統默認臨界     【cat /etc/profile|grep umask能夠查看默認的umask值】spa

增長文件全部用戶組可執行權限orm

chmod a+x log2012.log 【有的腳本沒法執行就是沒有x權限】

同時修改不一樣用戶權限,逗號分隔htm

chmod ug+w,o-x log201.log

使用「=」設置權限blog

chmod u=x hhh.txt ==> chmod 100 hhh.txt

爲全部用戶分配讀權限

chmod a=r file

【更多參考】Linux 用戶和用戶組詳解
相關文章
相關標籤/搜索