Linux offers write protection by allowing you to set files as immutable, to do this you will need to set set a special bit. Once this bit is set no one can delete or modify file, this includes the root user. The only user that can set and clear immutable bit is the root user.

List File attributes

To list what bits are set use ls -lo No bits set

lsattr
------------- ./testfile.txt

Immutable bit set (see schg flags are set)

lsattr
----i-------- ./testfile.txt

Set file immutable bit

chattr +i testfile.txt

Clear file immutable bit

chattr -i testfile.txt

Other Attributes

chattr also supports a number of other attributes

Useful options

chattr

For more information on the usage of chattr and the attributes that can be set see the man page at https://man7.org/linux/man-pages/man1/chattr.1.html