How to change hosts file on android

I successfully rooted my Samsung Galaxy Mini (android 2.2.1) and thought that I could change something (as root can usually do).

I would like to change the hosts file to android to include some local addresses. However, I am still receiving a message that I do not have permission to do so. I tried the following options:

  • adb push /path/to/my/new/hosts /system/etc ... and I got a Read-only file system response.

  • directly in the shell of the phone. But that didn't work either. I can do su in the console, but cannot change the file.

Is it not strange that as a superuser I am not allowed to modify some files?

+71
android hosts
Oct 17 2018-11-17T00:
source share
4 answers

You have root, but you still need to remount / read / write the system

 $ adb shell $ su $ mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system 

Go here for more information: Install a read / write file system .

+64
Oct 17 '11 at 2:00
source share
 $ adb shell $ su $ mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system 

This assumes your / system is yaffs2, and in / dev / block / mtdblock 3 is a simpler / better way to do this on most Android phones.

 adb shell $ su # mount -o remount,rw /system 

Done. It just talks about rebooting / reading and writing the system, you do not need to specify the file system or mount location.

+42
Jan 05 '12 at 21:00
source share

In my case, this really did not work - that is, in order to overwrite the hosts file, you must follow its instructions, that is:

 ./emulator -avd myEmulatorName -partition-size 280 

and then in another terminal (clicking on the new hosts / tmp / hosts file):

 ./adb remount ./adb push /tmp/hosts /system/etc 
+14
Nov 23 '11 at 19:10
source share

Probably the easiest way would be to use this Hosts Editor application. You must have root

+12
Jul 11 2018-12-12T00:
source share



All Articles