Only superuser (root) or processes with label CAP_LINUX_IMMUTABLE can run chattr
.
The basic usage of chattr
is to protect files or folders from moderation. For instance, to protect file $FILE
, run this command:
chattr +i $FILE
Files with attribute i
cannot be deleted, renamed or modified. Links cannot be created too. To delete the mark, run the command below.
chattr -i $FILE
The command lsattr
is to list the attributes of current files. Here is an example.
lsattr $FILE