linux lsattr chattr

linux 文件有一些特殊属性, 可以用lsattr 和 chattr 查看和设置
man 快速链接: lsattr chattr

chattr [ -RVf ] [ -v version ] [ mode ] files...
The format of a symbolic mode is +-=[acdeijstuADST].

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-merging (t), undeletable (u), no atime updates (A), synchronous directory updates (D), synchronous updates (S), and top of directory hierarchy (T).

The following attributes are read-only, and may be listed by lsattr(1) but not modified by chattr: huge file (h), compression error (E), indexed directory (I), compression raw access (X), and compressed dirty file (Z).

a(append only):如果设置了a属性,则这个文件只能增加数据,不允许任何进程覆盖或截断这个文件。如果某个目录具有这个属性,那么只能在这个目录下建立和修改文件,而不能删除任何文件。
s(secure deletion):如果设置了s属性,则这个文件将从硬盘空间中完全删除。


标签: none