目錄權限測試

創建普通用戶falcon
本次操作在falcon家目錄下執行,test目錄中默認文件644,目錄755
[root@www test]# pwd
/home/falcon/test
[root@www falcon]# ll
total 4
d--------- 3 root root 4096 Feb 25 22:33 test
 
[root@www test]# ll
total 12
drwxr-xr-x 2 daemon daemon 4096 Feb 25 22:32 one
-rw-r--r-- 1   daemon daemon    4    Feb 25 22:33 three
-rw-r--r-- 1   daemon daemon    4    Feb 25 22:32 two
 
 
爲什麼權限設置默認主目錄755root.root;裏面daemon.daemon目錄755,文件644
[root@www falcon]# ll
total 4
drwxr-xr-x 6 root root 4096 Feb 25 23:13 test
[falcon@www test]$ ll
drwxr-xr-x 2 daemon daemon 4096 Feb 25 22:32 one
-rw-r--r-- 1 daemon daemon    4 Feb 25 23:13 three
[falcon@www test]$ echo fafa >>three
-bash: three: Permission denied
 [falcon@www test]$ mkdir eight
mkdir: cannot create directory `eight': Permission denied
[falcon@www test]$ touch  night
touch: cannot touch `night': Permission denied
[falcon@www test]$ rm -f three
rm: cannot remove `three': Permission denied
無法修改文件,無法創建文件目錄,無法刪除文件
結論:安全
 
目錄權限000
[falcon@www ~]$ cd test/
-bash: cd: test/: Permission denied
[falcon@www test]$ echo "fafa">>sh
-bash: sh: Permission denied
[falcon@www test]$ sh four
sh: four: Permission denied
[falcon@www test]$ cat four
cat: four: Permission denied
[falcon@www test]$ mkdir seven
mkdir: cannot create directory `seven': Permission denied
[falcon@www test]$ touch seven
touch: cannot touch `seven': Permission denied
 
什麼都幹不了
 
目錄權限001
[root@www falcon]# chmod 001 test;ll
total 4
d--------x 3 root root 4096 Feb 25 22:33 test
 
[falcon@www test]$ ll
ls: .: Permission denied
[falcon@www test]$ mkdir seven
mkdir: cannot create directory `seven': Permission denied
[falcon@www test]$ touch eight
touch: cannot touch `eight': Permission denied
[falcon@www test]$ cat four
11111
[falcon@www test]$ sh sh
two
[falcon@www test]$ echo "fafa">>sh
-bash: sh: Permission denied
 
無法查看目錄列表,無法修改文件,無法刪除文件,只能查看已知文件
 
目錄權限003
[falcon@www test]$ ll
ls: .: Permission denied
[falcon@www test]$ echo 2222>>sh
-bash: sh: Permission denied
[falcon@www test]$ mkdir falcon
[falcon@www test]$ touch four
[falcon@www test]$
無法查看目錄列表,可以創建文件,目錄,但是無法修改已有文件
 
目錄權限005
[falcon@www test]$ ll
drwxrwxr-x 2 falcon falcon 4096 Feb 25 22:59 falcon
-rw-r--r-- 1 root   root      0 Feb 25 22:53 five
-rw-rw-r-- 1 falcon falcon    6 Feb 25 22:59 four
drwxr-xr-x 2 daemon daemon 4096 Feb 25 22:32 one
-rw-r--r-- 1 daemon daemon   23 Feb 25 22:50 sh
drwxrwxr-x 3 falcon falcon 4096 Feb 25 23:02 six
[falcon@www test]$ echo 222 >> sh
-bash: sh: Permission denied
[falcon@www test]$ touch  sh2
touch: cannot touch `sh2': Permission denied
[falcon@www test]$ mkdir sh2
mkdir: cannot create directory `sh2': Permission denied
[falcon@www test]$ cat sh
#!/bin/bash
echo "two"
可以查看目錄,文件,但無法修改
 
目錄權限007
[falcon@www test]$ echo eeee >>three
-bash: three: Permission denied
無法修改已有文件
 
結論其他組w權限可以可以創建文件,目錄,危險
 
下面爲反向測試。如果給了不該給的權限會造成什麼後果
目錄權限022
[falcon@www test]$ rm -f three
rm: cannot remove `three': Permission denied
[falcon@www test]$ ll
ls: .: Permission denied
[falcon@www test]$ ll
ls: .: Permission denied
[falcon@www test]$ mkdir touch
mkdir: cannot create directory `touch': Permission denied
[falcon@www test]$ touch v
touch: cannot touch `v': Permission denied
[falcon@www test]$ rm -f four
rm: cannot remove `four': Permission denied
[falcon@www test]$ rm -fr six
rm: cannot lstat `six': Permission denied
只具有2的權限還算安全
 
目錄權限023
[falcon@www test]$ echo 111 >> v
[falcon@www test]$ rm -f three
[falcon@www test]$ echo 222 >>four
-bash: four: Permission denied
[falcon@www test]$ ll
ls: .: Permission denied
無法查看目錄,無法修改文件,但是可以創建文件
 
[root@www test]# ll
-rw-rw-r-- 1 falcon falcon    4 Feb 25 23:25 v
[falcon@www test]$ cat sh
#!/bin/bash
echo "222"
[falcon@www test]$ sh sh
222
結論:wr必須在一起纔有用處,雖然無法修改已有文件,但已經可以往裏面插入文件了,並執行文件
 
所以。其他組擁有w權限危險
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章