chattr(change attribute)
chattr(change attribute)功能说明:改变文件属性。
语 法:chattr [-RV][-v<版本编号>][+/-/=<属性>][文件或目录...]
补充说明:这项指令可改变存放在ext2文件系统上的文件或目录属性,这些属性共有以下8种模式:
a:让文件或目录仅供附加用途。
b:不更新文件或目录的最后存取时间。
c:将文件或目录压缩后存放。
d:将文件或目录排除在倾倒操作之外。
i:不得任意更动文件或目录。
s:保密性删除文件或目录。
S:即时更新文件或目录。
u:预防以外删除。
参 数:
-R 递归处理,将指定目录下的所有文件及子目录一并处理。
-v<版本编号> 设置文件或目录版本。
-V 显示指令执行过程。
+<属性> 开启文件或目录的该项属性。
-<属性> 关闭文件或目录的该项属性。
=<属性> 指定文件或目录的该项属性。
chattr
chattr [options] mode files
Modify file attributes. Specific to Linux Second and Third Extended Filesystem (ext2 and ext3). Behaves similarly to symbolic chmod, using +, -, and =. mode is in the form opcode attribute. See also lsattr.
Options
Modify directories and their contents recursively.
Print modes of attributes after changing them.
Set the file's version.
Opcodes
Add attribute.
Remove attribute.
Assign attributes (removing unspecified attributes).
Attributes
Don't update access time on modify.
Append only for writing. Can be set or cleared only by a privileged user.
Compressed.
No dump.
Immutable. Can be set or cleared only by a privileged user.
Journalled file. This is useful only in cases where you are using an ext3 filesystem mounted with the data="ordered" or data="writeback" attributes. The data="journalled" option for the filesystem causes this operation to be performed for all files in the system and makes this option irrelevant.
Synchronous updates.
Secure deletion. The contents are zeroed on deletion, and the file cannot be undeleted or recovered in any way.
Undeletable. This causes a file to be saved even after it has been deleted, so that a user can undelete it later.
Example
chattr +a myfile