下面顯示了tomcat在刪除owner是本身的文檔時出錯了,提示Permission denied.tomcat
這是由於用戶tomcat在該文檔的父目錄權限裏並無w的權限.雖然tomcat是該文檔的owner,可是刪除該文檔也是對父目錄的修改,所以在用戶沒有父目錄的w權限裏,提示權限不足ide
drwxr-xr-x 2 root root 4096 Nov 21 21:02 tomcat drwxr-xr-x. 13 root root 4096 May 30 21:42 usr drwxr-xr-x. 19 root root 4096 Jul 15 02:29 var [root@wang ~]# touch /tomcat/xxx [root@wang ~]# chown tomcat:tomcat /tomcat/xxx [root@wang ~]# ll /tomcat/xxx -rw-r--r-- 1 tomcat tomcat 0 Nov 21 21:03 /tomcat/xxx [root@wang ~]# su - tomcat [tomcat@wang ~]$ rm -rf /tomcat/xxx rm: cannot remove `/tomcat/xxx': Permission denied [tomcat@wang ~]$
修改父目錄的權限,將w的權限給予用戶tomcat3d
[root@wang tomcat]# chmod 757 /tomcat
從下圖中可見,用戶tomcat對於xxx文檔的父目錄/tomcat有w的權限,因此刪除成功了blog
drwxr-xrwx 2 root root 4096 Nov 21 21:03 tomcat drwxr-xr-x. 13 root root 4096 May 30 21:42 usr drwxr-xr-x. 19 root root 4096 Jul 15 02:29 var [root@wang tomcat]# su - tomcat [tomcat@wang ~]$ rm /tomcat/xxx [tomcat@wang ~]$ ll /tomcat/ total 0 [tomcat@wang ~]$
也能夠直接把父目錄的owner轉給tomcat,最快的方法,這裏還用了遞歸,其實不用也能夠遞歸
[root@wang tomcat]# chown -R tomcat:tomcat /tomcat