The chattr
command can change the attributes of files or directories stored on the ext2
file system.
chattr [-vRV] [mode] [files]
-R
: Recursively process, including all files and subdirectories in the specified directory.-v <version num>
: Set the version number of the file or directory.-V
: Display the process of the command execution.+ <attribute>
: Enable the specified attribute for the file or directory.- <attribute>
: Disable the specified attribute for the file or directory.= <attribute>
: Specify the attribute for the file or directory.
a
: File or directory is only for append functionality.b
: Do not update the last access time for the file or directory.c
: Compress the file or directory.d
: Exclude the file or directory from a dump.i
: Make the file or directory immutable.s
: Securely delete the file or directory.S
: Synchronously update the file or directory.u
: Prevent accidental deletion of the file or directory.
Prevent file.txt
from being modified.
chattr +i file.txt
Add two attributes to the file.txt
file.
chattr +ac file.txt
Specify the attributes of the file.txt
file.
chattr =i file.txt
https://github.com/WindrunnerMax/EveryDay
https://man.linuxde.net/chattr
https://www.howtoforge.com/linux-chattr-command/
https://www.runoob.com/linux/linux-comm-chattr.html