search
Homephp教程PHP开发Linux parent directory permissions affect subdirectory file operations

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 ~]$

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

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 ~]$

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


Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!