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.
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.