linux设置只读属性,可以防webshell

##对目录设置只读

root@ubuntu1204:~/test# chattr +i wwwroot/

root@ubuntu1204:~/test# ls

wwwroot

#已经加上只读属性了

root@ubuntu1204:~/test# lsattr

----i--------e- ./wwwroot

root@ubuntu1204:~/test# cd wwwroot/

#目录下的文件依然可改

root@ubuntu1204:~/test/wwwroot# echo "0" >> index.php

root@ubuntu1204:~/test/wwwroot# cat index.php

fuckyou

0

#不可创建新文件

root@ubuntu1204:~/test/wwwroot# touch webshell.php

touch: cannot touch `webshell.php': Permission denied

root@ubuntu1204:~/test/wwwroot# cd ..

#所有文件设置

 只读

root@ubuntu1204:~/test# chattr +i wwwroot/*

root@ubuntu1204:~/test# cd wwwroot/

root@ubuntu1204:~/test/wwwroot# echo "0" >> index.php

-bash: index.php: Permission denied

root@ubuntu1204:~/test/wwwroot# cat index.php

fuckyou

0


你可能感兴趣的:(安全防护)