Linux parent directory permissions affect sub-directory file operations

Source: Internet
Author: User
Tags parent directory

The following shows that Tomcat made an error when deleting owner's own document, prompting permission denied.

This is because user Tomcat does not have W permissions in the document's parent directory permissions. Although Tomcat is the owner of the document, the deletion of the document is also a modification to the parent directory, so the user does not have permission to do so in the W permission without the parent directory.

drwxr-xr-x   2 root  root    4096 Nov 21 21:02 tomcatdrwxr-xr-x. 13 root  root    4096 May 30 21:42 usrdrwxr-xr-x. 19 root  root    4096 jul 15 02:29 var[[email protected] ~]# touch /tomcat/xxx[[email  protected] ~]# chown tomcat:tomcat /tomcat/xxx [[email protected] ~]#  ll /tomcat/xxx-rw-r--r-- 1 tomcat tomcat 0 nov 21 21:03 / Tomcat/xxx[[email protected] ~]# su - tomcat[[email protected] ~]$ rm  -rf /tomcat/xxx rm: cannot remove  '/tomcat/xxx ':  permission denied[[ email protected] ~]$ 

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/8A/9B/wKiom1g1DS_Aq9JoAABaJs-wjI8837.png "title=" Qq20161123113059.png "alt=" Wkiom1g1ds_aq9joaabajs-wji8837.png "/>

Modify the permissions of the parent directory to give the user tomcat the permissions of W

[Email protected] tomcat]# chmod 757/tomcat

From this, user Tomcat has the W permission for the parent directory of the XXX document/TOMCAT, so the deletion succeeded

DRWXR-XRWX 2 root root 4096 Nov 21:03 tomcatdrwxr-xr-x.  Root root 4096 May 21:42 usrdrwxr-xr-x. Root root 4096 Jul 02:29 var[[email protected] tomcat]# su-tomcat[[email protected] ~]$ rm/tomcat/xxx [email Protected] ~]$ ll/tomcat/total 0[[email protected] ~]$

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/8A/97/wKioL1g1DNqh5SY4AAA60rXeeXU855.png "title=" Qq20161123112932.png "alt=" Wkiol1g1dnqh5sy4aaa60rxeexu855.png "/>

You can also directly to the parent directory owner to Tomcat, the quickest way, here also used recursion, actually do not have to

[Email protected] tomcat]# chown-r Tomcat:tomcat/tomcat


This article from "Dream do not know is a guest" blog, reproduced please contact the author!

Linux parent directory permissions affect sub-directory file operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.