linux 文件、目录写保护小技巧

linux 文件、目录写保护小技巧

[root@book ~]# chattr +i a.txt
[root@root ~]# rm -f a.txt
rm: cannot remove a.txt': Operation not permitted [root@book ~]# ls anaconda-ks.cfg a.txt Desktop install.log install.log.syslog [root@book ~]# chattr -i a.txt [root@book ~]# rm -f a.txt [root@book ~]# ls anaconda-ks.cfg Desktop install.log install.log.syslog 保护目录: [root@root root]# mkdir test [root@root root]# chattr +i test [root@root root]# rm -fr test rm: cannot remove directory test': Operation not permitted

一个小技巧 希望能帮到有用的童鞋

touch可以创建空文本。Linux对文件和文件夹不铭感的。

这个确实很适用 有个chattr +a 还是 i 有点忘了 反正只能增加数据不能删除。 对管理员日志文件是非常有帮助的

**回复 3# 战虎 **

append only 加a话是只能追加....就是改变文件的属性而已