歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Linux文件權限,chmod

Linux文件權限,chmod

日期:2017/3/1 16:17:19   编辑:關於Linux
Linux文件權限,chmod 權限符號意義 符號 代表意義 數字 r 文件:可讀 路徑:僅能讀取路徑結構列表 4 w 文件:可寫 路徑:可新增、刪除、移動路徑下的文件 2 x 文件:可執行 路徑:可進入該路徑,訪問該路徑下的文件 1 s suid:僅對二進制文件有效,如/usr/bin/passwd sgid:對文件和路徑都有效 使文件有暫時擁有所有者或群組的權限 4 2 t sbit:主要對路徑有效。只能刪除自建的文件,如/tmp/ 1 主要語法 chmod [option] mode[,mode]... file... chmod [option] octal-mode file... mode 改變文件權限可以通過2種模式。符號模式和8進制數字模式。 符號模式 chmod u(擁有者) g(群組) o(其他) a(所有) +(加入) -(減去) =(設定) r(可讀) w(可寫) x(可執行) s(suid/sgid) t(sbit) file 8進制數字模式 suid/sgid/sbit 擁有者 群組 其他 chomod 0-7 0-7 0-7 0-7 file r=4,w=2,x=1,rwx=7,rw=6,rx=5 suid=4,sgid=2,sbit=1 用例 1 用2種模式改變文件權限,將此文件變成可執行文件,並且其他人無法修改 Linux代碼 $ chmod 755 ~/testfile $ chmod u=rwx,go=rx ~/testfile 2 使文件對於所有用戶,添加可寫的權限 Linux代碼 $ chmod a+w ~/testfile 3 用2種模式,給可執行文件加入suid權限 Linux代碼 $ chmod 4755 ~/testfile //testfile原權限為755 $ chomd u+s ~/testfile 4用2種模式,給路徑加入sgid權限。常用於群組中用戶間數據的共享 Linux代碼 $ chomd 2755 ~/testpath/ //testpath原權限為755 $ chmod g+s ~/testpath/ 5 用2種模式,給路徑加入sbit權限 Linux代碼 $ chmod 1755 ~/testpath //tsetpath原權限為755 $ chmod o+t ~/testpath
Copyright © Linux教程網 All Rights Reserved