0

I would like to lock the /etc/hosts file somehow in a way that only someone else can unlock it, possibly using a lock code.

I would then give the passcode to someone else.

I'm running Ubuntu 10.10.

3
  • 1
    just one word: why?
    – akira
    Dec 18, 2010 at 12:14
  • I change it otherwise. Works fantastic on a jailbroken iPhone with lockdown. Dec 18, 2010 at 22:58
  • Tell us more about this desire to constantly change /etc/hosts.
    – Allen
    Dec 19, 2010 at 12:54

2 Answers 2

3

Create an account for the other person and add it to the admin group (gives sudo access). Take yourself out of the admin group, so you can't use sudo.

1
  • +1. Not sure how else to do it.
    – oKtosiTe
    Dec 18, 2010 at 16:10
1

As far as I know, Pass codes on files nearly always (well every time I have seen) uses third party software in order to encrypt the file.

I do not know of any software that will accomplish what you want as the file needs to be read normally by the OS. If you were to some how encrypt it, then someone else could always just delete it and recreate it.

What you want to do is to look in to standard file level protection and only give certain groups access to the file - such as Root/Administrators. You can read up about Linux permissions using chmod here.

2
  • The problem of course being that–at least that's my assumption–the asker is the root user of the system. My knowledge is by no means definitive, but I'd be surprised if there is any way to protect any file from being deleted/replaced by root.
    – oKtosiTe
    Dec 18, 2010 at 13:07
  • @oKtosiTe - My thoughts exactly, Chmod is the only solution I can think of - but that only works for machines with multiple users.... Anything that encrypts/passcodes the file will make it inaccessible to the system itself so kind of pointless... It is a hard one, but chmod is the best solution. Dec 18, 2010 at 14:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .