recherche
Maisonphp教程PHP开发linux 父目录权限影响子目录文件操作

下面显示了tomcat在删除owner是自己的文档时出错了,提示Permission denied.

这是因为用户tomcat在该文档的父目录权限里并没有w的权限.虽然tomcat是该文档的owner,但是删除该文档也是对父目录的修改,因此在用户没有父目录的w权限里,提示权限不足

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

   wKioL1g1FQKRNt6DAAAEXizhf1w010.png

修改父目录的权限,将w的权限给予用户tomcat

[root@wang tomcat]# chmod 757 /tomcat

   

从下图中可见,用户tomcat对于xxx文档的父目录/tomcat有w的权限,所以删除成功了

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

   wKioL1g1FQKRNt6DAAAEXizhf1w010.png

也可以直接把父目录的owner转给tomcat,最快的方法,这里还用了递归,其实不用也可以

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

   


Déclaration
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn

Outils d'IA chauds

Undresser.AI Undress

Undresser.AI Undress

Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover

AI Clothes Remover

Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool

Undress AI Tool

Images de déshabillage gratuites

Clothoff.io

Clothoff.io

Dissolvant de vêtements AI

AI Hentai Generator

AI Hentai Generator

Générez AI Hentai gratuitement.

Article chaud

R.E.P.O. Crystals d'énergie expliqués et ce qu'ils font (cristal jaune)
4 Il y a quelques semainesBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Meilleurs paramètres graphiques
4 Il y a quelques semainesBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Comment réparer l'audio si vous n'entendez personne
1 Il y a quelques moisBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Commandes de chat et comment les utiliser
1 Il y a quelques moisBy尊渡假赌尊渡假赌尊渡假赌

Outils chauds

MantisBT

MantisBT

Mantis est un outil Web de suivi des défauts facile à déployer, conçu pour faciliter le suivi des défauts des produits. Cela nécessite PHP, MySQL et un serveur Web. Découvrez nos services de démonstration et d'hébergement.

Adaptateur de serveur SAP NetWeaver pour Eclipse

Adaptateur de serveur SAP NetWeaver pour Eclipse

Intégrez Eclipse au serveur d'applications SAP NetWeaver.

VSCode Windows 64 bits Télécharger

VSCode Windows 64 bits Télécharger

Un éditeur IDE gratuit et puissant lancé par Microsoft

SublimeText3 version anglaise

SublimeText3 version anglaise

Recommandé : version Win, prend en charge les invites de code !

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Puissant environnement de développement intégré PHP