How do I make a file NOT modifiable?
You can set the "immutable" attribute with most filesystems in Linux.
chattr +i foo/bar
To remove the immutable attribute, you use -
instead of +
:
chattr -i foo/bar
To see the current attributes for a file, you can use lsattr:
lsattr foo/bar
The chattr(1) manpage provides a description of all the available attributes. Here is the description for i
:
A file with the `i' attribute cannot be modified: it cannot be deleted
or renamed, no link can be created to this file and no data can be
written to the file. Only the superuser or a process possessing the
CAP_LINUX_IMMUTABLE capability can set or clear this attribute.