Linux chattr Command
Linux chattr command is used to change the file attributes.
This instruction can be changed is stored on the ext2 file system file or directory attributes, which are divided into the following 8 modes:
- a: the file or directory only make additional uses.
- b: do not update the last access time of the file or directory.
- c: After the file or directory will be stored compressed.
- d: exclude files or directories outside of the dumping operation.
- i: file or directory can not be any changes.
- s: Confidentiality delete files or directories.
- S: Instant update the file or directory.
- u: prevent outside deleted.
grammar
chattr [-RV][-v<版本编号>][+/-/=<属性>][文件或目录...]
parameter
-R Recursive processing, all files and subdirectories in the specified directory be dealt with.
-v <version number> settings file or directory versions.
-V Display process execution instruction.
+ <Properties> to open the file or directory attributes.
- <Property> to close the file or directory attributes.
= <Attribute> Specify the file or directory attributes.
Examples
With the chattr command to prevent a critical system files are modified:
chattr +i /etc/resolv.conf
lsattr /etc/resolv.conf
It will display the following attributes
----i-------- /etc/resolv.conf
So that a file can only be entered, additional data, but can not be deleted for a variety of log files:
chattr +a /var/log/messages