Force Linux file to be truly read only.
Posted: Tue Apr 22, 2003 3:13 pm
You can run chmod on a file so that it only has the "read" property - but this will still not prevent a process running as root from changing its contents. (Nor will it prevent you from forcing a change.) However, there IS a way of making it truly read only, so long as the filesystem is ext2.
Issue the following command:
chattr +i filename
To change the file back, so that you can write to it, you would use the following:
chattr -i filename
Both commands must be issued when logged in as root.
Issue the following command:
chattr +i filename
To change the file back, so that you can write to it, you would use the following:
chattr -i filename
Both commands must be issued when logged in as root.