+ -
当前位置:首页 → 问答吧 → 文件删不掉 Operation not permitted

文件删不掉 Operation not permitted

时间:2011-12-28

来源:互联网

在CentOS下,想删除/var/log/httpd的一些文件,不能成功。
rm -f d 提示 rm: cannot remove `d': Operation not permitted

当前账户是root, ls -l d 的结果:
-rw-r--r--. 1 root root 0 Dec 26 10:06 d

lsattr d 的结果
-----a-------e- ./d

另外:
cp d e
e文件能创建成功, 但e文件又不能被删除了。


还有yum update httpd也不成功,有一个错误提示:
error: unpacking of archive failed on file /var/log/httpd: cpio: lsetfilecon

怎么才能删除这些文件呢?

作者: myblind   发布时间: 2011-12-28

看到lsetfilecon这个词就想到好像是跟selinux有关
getenforce看看是不是启用了selinux的?

作者: askandstudy   发布时间: 2011-12-28

是Permissive

# setenforce 0
# rm -f d
rm: cannot remove `d': Operation not permitted
# setenforce 1
# rm -f d
rm: cannot remove `d': Operation not permitted
# setenforce Enforcing
# rm -f d
rm: cannot remove `d': Operation not permitted
# setenforce Permissive
# rm -f d
rm: cannot remove `d': Operation not permitted

作者: myblind   发布时间: 2011-12-28

修改/etc/selinux/config之后重启

# getenforce
Disabled
# rm -f d
rm: cannot remove `d': Operation not permitted

作者: myblind   发布时间: 2011-12-28

不是enforcing就不会受selinux影响了
那再获取acl权限看看呢
getfacl d

再看看/var/log/下messages,secure,audit/audit.log等等日志有没有什么明确的提示信息

作者: askandstudy   发布时间: 2011-12-28

前面没有仔细看,你的lsattr里那个文件有个a,是只能追加不能删除的


chattr +a d
chattr -a d

作者: askandstudy   发布时间: 2011-12-28

mark
以前还真没碰到过

作者: Arnold9009   发布时间: 2011-12-28