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.


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>

  • 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 '12 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 '12 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 '12 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 '12 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 '12 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.