權限規則:r=4,w=2,x=1,-=0。spa
例:-rwxr-xr-x 755test
chmod命令用做修改文件和目錄權限。該命令有三種不一樣語法:權限
一、chmod [-R] xyz 文件名 (這裏xyz表明數字)語法
-R 表示級聯更改touch
[root@localhost~]#touch test.sh文件
[root@localhost~]# ll test.shco
-rw-r--r-- 1 root root 0 11月 10 08:55 test.sh數字
[root@localhost~]# chmod 755 test.shlocalhost
[root@localhost~]# ll test.sh
-rwxr-xr-x 1 root root 0 11月 10 08:55 test.sh
二、由於9個屬性分別是user,group,others。因此使用u,g,o代替它們三個的屬性。此外,a表明all即所有。
[root@localhost~]# ll test.sh
-rwxr-xr-x 1 root root 0 11月 10 08:55 test.sh
[root@localhost~]# chmod u=rw,g=rw,o=r test.sh
[root@localhost~]# ll test.sh
-rw-rw-r-- 1 root root 0 11月 10 08:55 test.sh
三、另外還能夠針對u,g,o,a增長或減小某個權限。
[root@localhost~]# ll test.sh
-rw-rw-r-- 1 root root 0 11月 10 08:55 test.sh
[root@localhost~]# chmod u+x,o+x test.sh
[root@localhost~]# ll test.sh
-rwxrw-r-x 1 root root 0 11月 10 08:55 test.sh