Is there a way to make a file readonly permanently in linux. Or can I put a password to a file to make it readonly, then apply that password again to change its permission, or before they can alter it.
Only way to do that would be to write the file in question on a media which is writable only once, e.g. a CD-ROM.
Any other solution is possible to circumvent by root. If the file you'd like to make non-writable is one of system files, e.g.
/etc/passwd, you'd either have to to live with many files being read-only or create a symlink from the file you want to protect, e.g.
/etc/passwd to a file residing on your read-only media, but that again would be easy to circumvent by
root, simply delete the symlink and create new content in its place.
So simple answer would be: No and there must be a better way of achieve whatever it is that you want to accomplish by making one or more files permanently read-only.
The only way you could have a file that is read only and still on the system is have an ISO file that then contains the read-only file. Then the file will be read-only as the ISO filesystem for CDRoms is read only. You could then mount the ISO file somewhere to allow access to the file. You don't need to write the ISO file to a CD.
However, if you ever need to modify the file, you need to create a new ISO file with the new file within the ISO file system as you cannot modify files within an ISO file system.