4

I run adb shell and append a line to /etc/hosts using

echo IP DNSName >> hosts

It works for a some time and then reverts back to having only a single entry for localhost.

Any idea what could cause this? I am using temp root using VISIONary and I am connecting my HTC Desire HD adbd via WiFi, because it refuses to identify my handset via USB.

1 Answer 1

2

No idea why it's doing it, but you could stop it by changing the permissions on the host file to read-only.

To set a file to read-only, log in as root via ADB (or use the Terminal application and log in as root) and then enter:

chmod 444 <path-to-hosts-file>

If you need to edit it again later on, enter:

chmod 644 <path-to-hosts-file>

5
  • I think you mean read-only. That should work as long as what's overwriting the file isn't an app that uses root, or the system itself doing it on boot.
    – davidbb
    Mar 4, 2012 at 22:58
  • Yes, that IS what I meant. DURRR. Thanks, I corrected it. If the perms are set to ro, nothing should be able to overwrite it unless it also can set file privs, which is unlikely.
    – Logos
    Mar 5, 2012 at 3:40
  • how do I set the file to read only? Anyway, its not on reboot. could it be a result of my "force close"ing an app and clearing its cache ?
    – epeleg
    Mar 5, 2012 at 13:20
  • Updated answer with more details on perms. Also, it would be most unlikely to be from force closing an app unless it's an ad blocker.
    – Logos
    Mar 5, 2012 at 17:39
  • No adblocker is involved. Nor does this help. It just keeps reverting even after I call chmod 444 hosts. Can I somehow log access to this file?
    – epeleg
    Mar 6, 2012 at 9:27

You must log in to answer this question.

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