chmod Operation not permitted如何解决

想删除某个文件,但是却提示操作无权限,被拒绝。


[root@vmlin0342 php]# chmod -R u+w labs/config/conf

chmod: changing permissions of `labs/config/conf/redis.ini': Operation not permitted
chmod: changing permissions of `labs/config/conf/mysql.ini': Operation not permitted

chmod: changing permissions of `labs/config/conf/zookeeper.ini': Operation not permitted

经过搜索,发现chattr可以修改文件的属性。

[root@vmlin0342 php]# chattr -i labs/config/conf/
[root@vmlin0342 php]# lsattr labs/config/conf/
----i-------- labs/config/conf/redis.ini
----i-------- labs/config/conf/mysql.ini
----i-------- labs/config/conf/zookeeper.ini

这样就可以修改文件了。

[root@vmlin0342 php]# chattr -R -i labs/config/conf/
[root@vmlin0342 php]# 
[root@vmlin0342 php]# lsattr labs/config/conf/
------------- labs/config/conf/redis.ini
------------- labs/config/conf/mysql.ini
------------- labs/config/conf/zookeeper.ini
[root@vmlin0342 php]# chmod -R 777 labs/config/conf/
[root@vmlin0342 php]# rm -rf labs
[root@vmlin0342 php]# ls -al
total 8
drwxr-xr-x 2 root root 4096 Apr 21 11:34 .
drwxr-xr-x 6 root root 4096 Apr 21 11:26 ..


至此,文件属性被修改,文件也已经被删除








你可能感兴趣的:(Linux)