文件删不掉 Operation not permitted

myblind 2011-12-28 06:33:25
在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

怎么才能删除这些文件呢?
...全文
802 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
askandstudy 2011-12-29
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 myblind 的回复:]

太感谢了,原来是父目录的a属性引起的。
[/Quote]


我也顺便复习了下都快忘光了的知识
myblind 2011-12-29
  • 打赏
  • 举报
回复
太感谢了,原来是父目录的a属性引起的。
askandstudy 2011-12-29
  • 打赏
  • 举报
回复
该文件的上层目录lsattr看看属性
myblind 2011-12-29
  • 打赏
  • 举报
回复
多谢各位,但似乎不是chattr的问题。

# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),6(disk),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

# getfacl d
# file: d
# owner: root
# group: root
user::rw-
group::r--
other::r--

# chattr -a d
# lsattr d
-------------e- d
# rm -f d
rm: cannot remove `d': Operation not permitted

还有另外一个log文件,apache写入了数据,但是root用vim不能编辑:
Can't open file for writing
子谋 2011-12-29
  • 打赏
  • 举报
回复
首先,同意#5和#7,如果lsattr查看有a权限,显然是无法删除的……
另外,抛开这种特殊权限的影响,文件能否被删除,是由文件所在的目录决定的,如果目录对某个用户没有w权限,文件一样无法删除……
nehc 2011-12-28
  • 打赏
  • 举报
回复
学习学习 chattr

完全是这家伙在作怪
freetstar 2011-12-28
  • 打赏
  • 举报
回复
A file with the `a' attribute set can only be open in append mode for
writing. Only the superuser or a process possessing the
CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

chattr -a d试试先
Arnold9009 2011-12-28
  • 打赏
  • 举报
回复
mark
以前还真没碰到过
askandstudy 2011-12-28
  • 打赏
  • 举报
回复
前面没有仔细看,你的lsattr里那个文件有个a,是只能追加不能删除的


chattr +a d
chattr -a d
askandstudy 2011-12-28
  • 打赏
  • 举报
回复
不是enforcing就不会受selinux影响了
那再获取acl权限看看呢
getfacl d

再看看/var/log/下messages,secure,audit/audit.log等等日志有没有什么明确的提示信息
myblind 2011-12-28
  • 打赏
  • 举报
回复
修改/etc/selinux/config之后重启

# getenforce
Disabled
# rm -f d
rm: cannot remove `d': Operation not permitted
myblind 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

askandstudy 2011-12-28
  • 打赏
  • 举报
回复
看到lsetfilecon这个词就想到好像是跟selinux有关
getenforce看看是不是启用了selinux的?

19,620

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧