FreeBSD 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

ls -lo
drwx------  3 root  wheel  uarch 12 Oct 13  2021 testfile.txt

Immutable bit set (see schg flags are set)

ls -lo
drwx------  3 root  wheel  schg,uarch 12 Oct 13  2021 testfile.txt

Set file immutable bit

chflags schg testfile.txt

Clear file immutable bit

chflags noschg testfile.txt

Other Flags

chflags also supports a number of other flags