无意中发现,办公用的 linux系统中存在一个目录无法删除问题,因为系统中用的root用户,这个目录没有做过特殊设置,比如chattr +i 设置等操作,感觉很奇怪。
rm -rf vpn.conf
rm: cannot remove 'vpn.conf': Operation not permitted
查看文件的扩展flag
# lsattr vpn.conf
--------------e------- vpn.conf
e flag标记说明:
From 'man chattr':
Raw
The ’e’ attribute indicates that the file is using extents for mapping the blocks on disk. It may not be removed using chattr(1).
尝试去掉e标记
chattr -e vpn.conf
在查看文件的扩展flag
lsattr -d vpn.conf
-----a---------------- vpn.conf
出现a标记,chattr的man 手册a标记说明:
a A file with the 'a' attribute set can only be opened in append mode for writing. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
继续去掉a标记
chattr -a vpn.conf
然后执行rm,可以删除了。