Linux chattr command is used to change file attributes.
The instructions may change stored on the ext2 file system file or directory attributes that total the following 8 modes:
- a: Let the file or directory is for additional uses.
- b: do not update the last access time of the file or directory.
- c: to store the file or directory compression.
- d: the file or directory exclude tilting operation.
- i: not any change on a file or directory.
- s: Confidentiality delete files or directories.
- S: Instant update a file or directory.
- u: prevent accidental erasure.
grammar
the chattr [- the RV ] [- V <version number>] [+ / - / = <attribute>] [file or directory ...]
parameter
-R recursive processing, all files and subdirectories in the specified directory dealt with together.
-v <version number> settings file or directory versions.
-V display process execution instruction.
+ <Properties> Properties to open the file or directory.
- <property> to close the file or directory attributes.
= <Attributes> Specify the file or directory attributes.
Examples
To prevent a critical system file is modified with the chattr command:
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, and additional data, but can not be deleted for a variety of log files:
chattr +a /var/log/messages