The root user is prompted with: Operation not permitted

情景还原

笔者今天在使用root用户删除服务器上的一个文件时,被系统告知:Operation not permitted。甚至不能使用chmod给777权限。

一开始我是很懵逼的状态,还有root用户操作不了的东西(原谅作者对Linux不是很深入了解)?

具体如下图所示:

解决方法
上面我们执行的chmod命令,其底层实现是chattr命令,用此命的功能更为强大,甚至可以锁定文件,即使root用户也操作不了此文件。

chattr是用来更改文件属性,lsattr可用来查看文件的属性,执行命令lsattr /webapps/.usr.ini便可以看到当前文件的属性;

可以发现当前文件有个i属性,查阅命令帮助文档可以看到有i属性的文件是不能修改的,更不可被删除,即使是root用户也不可。

既然知道了文件不能删除的原因是加了i属性,所以相应的解决方案就是把文件的i属性去除,然后再删除。
————————————————

chattr -i webapps   //去除i属性
rm -rf webapps      //删除文件夹
912sy.com download resources are from the network, only for learning and reference use, the copyright belongs to the original author, do not use for commercial purposes, please remove yourself within 24 hours after downloading.
If the content published on this site inadvertently violates your rights and interests, please contact us and the site will be deleted within one business day.If you encounter any problems please contact customer service QQ:2385367137
912sy " The root user is prompted with: Operation not permitted