The only way I know to do what you are asking for is with chattr(1) which as name suggest change files attributes.
Under attributes section you can read:
"A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be opened in write mode. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute."
--practical case:
: lsattr example.file
------------------- example.file
: ls -lh example.file
-rw------- 1 tntx tntx 15 Dec 23 20:43 example.file
: su -
Password:
root@foo: chattr +i example.file
root@foo: exit
logout
: lsattr example.file
----i-------------- example.file
: cat example.file
testing chattr
: echo "adding text" >> example.file
ksh93: example.file: cannot create [Operation not permitted]
Same with vi:
Read-only file, not written; use ! to override.
:w!
Error: example.file: Operation not permitted.
And then trying to mv:
: mv example.file example.file2
mv: cannot move 'example.file' to 'example.file2': Operation not permitted
What about cp:
: ls -lh example.file*
-rw------- 1 tntx tntx 15 Dec 23 20:43 example.file
-rw------- 1 tntx tntx 15 Dec 23 21:02 example.file2
: /usr/bin/lsattr example.file*
----i-------------- example.file
------------------- example.file2
So it fails because you can lock the file to be only readable by user but will be free to cp(1) and edit in new file.