The Linux chattr command is used to change file properties.
This directive alters the file or directory attributes stored on the ext2 file system, which have the following 8 modes:
A: Make the file or directory available for additional use only.
B: Do not update the last access time of the file or directory.
C: Compress the file or directory and store it.
D: Exclude files or directories from dumping operations.
I: Do not alter the file or directory arbitrarily.
S: Privacy delete files or directories.
S: Update files or directories instantly.
U: Remove outside of prevention.
Grammar:
[-RV][-v< version number >][+/-/=< Properties >][file or directory ...]
Parameters:
-R recursively handles all files and subdirectories under the specified directory.
-v< version number > set file or directory version.
-V Displays the instruction execution process.
+< Properties > Open the Item property of the file or directory.
-< Properties > Close the Item property of the file or directory.
The =< property > Specifies the Item property of the file or directory.
Example:
Use the chattr command to prevent a key file in the system from being modified:
Chattr +I/ECT/MIAN.CONFG
Lsattr/ect/main.confg
Allow a file to append data only to it, but not delete it, for various log files:
Chattr +a/etc/mysql.log
Linux Basic Command Learning (vi) Special properties of files