![chattr +ia 中的“a”有什么作用?](https://linux22.com/image/42110/chattr%20%2Bia%20%E4%B8%AD%E7%9A%84%E2%80%9Ca%E2%80%9D%E6%9C%89%E4%BB%80%E4%B9%88%E4%BD%9C%E7%94%A8%EF%BC%9F.png)
a
in是做什么的chattr +ia <filename>
?为什么要添加 thea
和 the i
?注意:我知道这i
是不可变的
答案1
The letters `acdeijstuADST' select the new attributes for the files: append only (a), compressed (c), no dump (d), extent format (e), immutable (i), data journalling (j), secure deletion (s), no tail-merg‐ ing (t), undeletable (u), no atime updates (A), synchronous directory updates (D), synchronous updates (S), and top of directory hierarchy (T).
具有此标志的文件将无法打开进行写入。这也会阻止某些潜在的破坏性系统调用,例如truncate()
或者unlink()
。
$ touch foo
$ chattr +a foo
$ python
> file("foo", "w") #attempt to open for writing
[Errno 1] Operation not permitted: 'foo'
> quit()
$ truncate foo --size 0
truncate: cannot open `foo' for writing: Operation not permitted
$ echo "Appending works fine." >> foo
$ cat foo
Appending works fine.
$ rm foo
rm: cannot remove `foo': Operation not permitted
$ chattr -a foo
$ rm foo
此选项是为日志文件设计的。