Home > php教程 > PHP开发 > Linux parent directory permissions affect subdirectory file operations

Linux parent directory permissions affect subdirectory file operations

高洛峰
Release: 2016-11-23 17:43:47
Original
1937 people have browsed it

The following shows that tomcat made an error when deleting the document whose owner is itself, prompting Permission denied.

This is because the user tomcat does not have w permissions in the parent directory permissions of the document. Although tomcat is the owner of the document, Deleting the document is also a modification to the parent directory, so if the user does not have the w permission of the parent directory, it will prompt that the permission is insufficient

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 ~]$
Copy after login

Linux parent directory permissions affect subdirectory file operations

Modify the permissions of the parent directory and give the w permission to the user tomcat

[root@wang tomcat]# chmod 757 /tomcat
Copy after login

As can be seen from the picture below, the user tomcat has w permissions on the parent directory/tomcat of the xxx document, so the deletion was successful

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 ~]$
Copy after login

Linux parent directory permissions affect subdirectory file operations

You can also directly transfer the owner of the parent directory to tomcat. The fastest way is here. I used recursion, but I can actually do it without it

[root@wang tomcat]# chown -R tomcat:tomcat /tomcat
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template