How to make a file permanently readable on Linux so that even root cannot edit it?

If I would like to lock the file as read-only. Even root cannot use the editor to change it, simply allowing any program to open it for reading only.

Any suggestions?

+8
linux
source share
3 answers

For files there is a "fixed" bit .

Programs (even running as root) cannot interfere with the file. Of course, root can cancel the bit, but most programs (especially non-malicious ones) will not pass by it.

Install it with

sudo chattr +i file 
+16
source share

you must have root perms

sudo chattr +i file

+3
source share

You can use Perl or another language to create a file lock.

How to lock a file in perl

But, root can kill the process, can access the file.

0
source share

All Articles