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(atime):如果设置了A属性,则这个文件的最后访问时间atime不能被修改。
a(append only):如果设置了a属性,则这个文件只能增加数据,不允许任何进程覆盖或截断这个文件。如果某个目录具有这个属性,那么只能在这个目录下建立和修改文件,而不能删除任何文件。
i(immutable):如果设置了i属性,则不能对这个文件做任何修该。如果某个目录具有这个属性,那么只能修改该目录下的文件,而不能建立和删除文件。
s(secure deletion):如果设置了s属性,则这个文件将从硬盘空间中完全删除。
u(undeletable):与s完全相反。如果设置了u属性,则这个文件虽然被删除了,但是还在硬盘空间中存在,还可以用来还原恢复。

参考

标签: none

添加新评论