chattr +i
しておくと削除も上書きも追記もできなくなる。
lsattr ファイル名
で属性確認し、
chattr -i
で属性削除。
$ touch hoge
$ chattr +i hoge
$ lsattr hoge
----i---------e------- hoge
$ echo aaa > hoge
zsh: 許可されていない操作です: hoge
$ echo aaa >> hoge
zsh: 許可されていない操作です: hoge
$ rm hoge
rm: 'always' を削除できません: 許可されていない操作です
$ chattr -i hoge
i
フラグの意味は:
i A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be opened in write mode.
Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.