Detailed explanation for using chattr,lsattr command
Chattr
Chattr
-: means to subtract a permission
+: means to increase a permission
=:
Options:
I: when used for a file, it means that the file cannot be deleted, cannot be modified, and can only be viewed
When used in a directory, it means that you cannot create or delete any files or directories under this directory. You can only modify existing files.
A: when used for a file, it means that the file cannot be deleted, can be viewed, and data can be added, but it cannot be modified by vim. It is often used to automatically append content in the log.
When used in a directory, it means that no files or directories can be deleted in this directory, only new files or directories can be created, files can be modified but deletion is not allowed.
How to use it:
Chattr + I |-I FILE
Chattr + a |-a FILE
Lsattr
-a: show all files and directories
-d: if the target is a directory, only the attributes of the directory itself are listed, not those of the subfiles