Reputation: 459
If I would like to lock a file as read-only. Even root can not use an editor to modify it, just allowing any program to open it read-only.
Any suggestions?
Upvotes: 13
Views: 8819
Reputation: 13065
There is an "immutable" bit for files.
Programs (even running as root) won't be able to tamper with the file. Of course, root can un-do the bit, but most programs (especially non-malicious ones) won't get past it.
Set it with
sudo chattr +i file
Upvotes: 25
Reputation: 306
You can use Perl or another language to create a file lock
But, root could kill the process can gain access to the file.
Upvotes: 0