Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the hosts file on android [closed]

Tags:

android

hosts

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

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

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

  2. directly in the shell on the phone. But this didn't work either. I can do su in the console, but cannot change the file.

Isn't it strange, that as super user I am not allowed to change some files?

like image 594
Filip Majernik Avatar asked Oct 17 '11 13:10

Filip Majernik


People also ask

How can I change host file in Android?

If your device is rooted, all you would have to do is to download a file explorer ( such as ES File Explorer File Manager - Android Apps on Google Play ) give it super user permission and enable the in-app setting which makes system files writable. You can then use the file explorer to replace or edit the hosts file.

Does Android have a hosts file?

The hosts file on Android devices is located in the '/etc/hosts' folder. This file is located in a read-only filesystem for security reason, it cannot be modified.

Can I edit hosts file on Android without root?

On non-rooted phone you cannot actually edit hosts file but it's possible to use VPN apps like Virtual Hosts or Personal DNS Filter (both are open-source, I've no affiliation with either) which intercept DNS traffic and look up a custom hosts file before making queries to configured upstream DNS server.


2 Answers

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

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

Go here for more information: Mount a filesystem read-write.

like image 114
Leif Andersen Avatar answered Sep 20 '22 14:09

Leif Andersen


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

This assumes your /system is yaffs2 and that it's at /dev/block/mtdblock3 the easier/better way to do this on most Android phones is:

adb shell su mount -o remount,rw /system 

Done. This just says remount /system read-write, you don't have to specify filesystem or mount location.

like image 25
Paul Avatar answered Sep 23 '22 14:09

Paul