Force Linux file to be truly read only.

Technical Q&A involving operating systems, networking, software, and hardware issues.

Moderator: jasonb

Post Reply
User avatar
jasonb
Site Administrator
Posts: 105
Joined: Tue Apr 22, 2003 1:54 pm
Location: Toronto, Canada
Contact:

Force Linux file to be truly read only.

Post by jasonb »

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