If you want to make a file immutable on linux you can use the following terminal commands:
sudo chattr +i filename
If you want to undo the file immutability, type:
sudo chattr -i filename
If you want to make an entire Directory with all its contents immutable, type:
sudo chattr -R +i path/to/directory
and to undoo, type:
sudo chattr -R -i path/to/directory
chattr works directly on the file-system level , which means it's more robust than the usual user-privilege and file-permissions stuff.
if you want to check the immutability status you can type
it'll give you an output with lots of dashes if it's got a -i- within the dashes that means the immutability is set.
there's lots of tutorials with more information and functionality like this onehttps://www.xmodulo.com/make-file-immutable-linux.html
if you care to know more