There is a tool called chattr that allows you to change/set file attributes on a GNU/Linux second extended (ext2) filesystem.
For example to protect myfile.txt, proceed as follows…
chattr +i myfile.txt
A file with the “i” (immutable) 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 pessessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.