Linux

chattr +ia 中的“a”是做什麼的?

  • May 7, 2011

ain是做什麼的chattr +ia <filename>?以及為什麼要將 與a結合起來添加i注意:我知道i是不可變的

  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).

手冊頁chattr

帶有此標誌的文件將無法打開寫入。這也阻止了某些具有潛在破壞性的系統呼叫,例如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

此選項專為日誌文件設計。

引用自:https://unix.stackexchange.com/questions/3634