Purpose: limit writing to /etc/hosts
to prevent me from editing the file without permission from someone that I entrust the password to. Note that I am the administrator of this Mac, so the password protection should prevent me from (or make it very difficult to) edit the file without the password.
Desired effect: If I try to edit the file with $ sudo vim /etc/hosts
or something of the like, it should not only prompt me for the admin password for the sudo
call but also prompt me for a password I set for the file. However, reading the file should not be restricted as various processes need access to this file.
Unsuccessful attempts:
- I haven’t tried creating a separate password-protected disk image to move
/etc/hosts
onto, but I’m quite sure that is not going to work. - A similar question was posed on AskUbuntu but the posted answer is not what I am looking for.
Note: This is my first ever question, so please let me know if I should make any edits. Thank you.