Any possible way to replace hosts file? - Honor Magic 2 Questions & Answers

I download the ad-block hosts file, try use adb send to phone:
adb push ./hosts /system/etc/
Got error message:
remote couldn't create file: Read-only file system
Try adb root and adb remount xxx also not work.
Are there any possible way can replace the hosts file? Thanks.

Becuase current no way to modify hosts, I am use "Block This!" to do ad-block.
official website: https://block-this.com/

You can't modify system files without root

Related

Pushing hosts file restarts device

I'm trying to play around with the hosts file through adb. I'm new to android from WinMo and trying to learn a few things but couldn't figure this one out.
when I push a new hosts file with:
Code:
adb push hosts /system/etc/hosts
a few seconds later the evo restarts and reverts back to the old hosts file with only localhost listed in there.
I ran into one tutorial that showed the person booting into recovery mode and moving the hosts file from the sdcard to the etc dir:
Code:
adb shell
mount /system
mount /sdcard
cp /sdcard/hosts /system/etc/hosts
exit
Does the hosts file have to be modified via recovery mode or am I doing something wrong by pushing it?
Any help or input is greatly appreciated.
Incase you dont know yet in the hundreds of post all over the rooting threads system is only writable in recovery. /system is nand locked when the OS is running.
ah ok. thanks.
now I'm a bit confused.
when in recovery mode after invoking
Code:
adb reboot recovery
I can't start a remote shell. I get the following error message:
Code:
D:\adb shell
- exec '/system/bin/sh' failed: No such file or directory (2) -
--EDIT--
Guess I just had to run the batch file toast put together. [http://link.geekfor.me/evorecovery]

[Q] cant copy big files (via USB-MTP, ADB)

hey!
I try to backup my backup. So I want to copy my nandroid-files from internal-SD to my computer. everything is working fine, but the two big files from data (810MB) and system (1200MB) cant be copied. If I try it with normal USB-MTP windows just ignores my copy-attempt. With adb pull I get an error:
adb pull sdcard/TWRP TWRP
results in copying everything instead of system and data: "failed to copy FROM to DEST: Permission denied"
any ideas?
I'm using JMZ-kernel, dev-unlock, root.
forgot to say: Also no access via Airdroid and ES Explorer/Root Explorer. I tried to copy those files somewhere on the SD-card, also tried to put them in a zip file.
The backup is in a special folder with protection, so you need to set the correct rights to copy the files, I think.
You may use these commands in Adb console:
adb shell
su
chmod -R 777 data/media/0/TWRP/
exit
After this it is possible to copy the files
Sent from my HTC One mini using xda app-developers app
THANKS!!!

Unerasable files pushed via ADB

Hi,
I recently pushed a folder (Download) to the sdcard of my OnePlus One via ADB in recovery. Now, I can't delete any of the files inside that folder via any (root) browser.
How can I fix that?
Thanks.
If you are unlocked, install Root Explorer, or the like, and check the directory permissions. Mine is set to 777, and I can delete it if I wish. Or you can change the permission of the files inside, and delete those, as you wish.
There are likely adp commands, as well. Perhaps someone will show with that know-how.
I tried that, though it unfortunately doesn't work via root browser.
I'll try it via adb later today.
adb remount (to gain rw-access to root partition)
adb shell rm -f <path to file> (to delete the apk)

[TIP] AdAway cannot write hosts file - Stock, rooted

This is for people that like to use the stock firmware (I'm one of them) and you are rooted with ElementalX. One of my main reasons to root the phone is to use AdAway (or similar) to get rid of annoying and useless ads.
Well, the hosts file is write protected by the stock Android and cannot be overwrite by AdAway, even if you give root access. AdAway suggests a work-around for this and this is how you apply it.
1. First run AdAway - it will fail writing the system hosts file, but the new hosts file is downloaded on the phone.
Now change to fastboot mode and then boot TWRP (there is no need for TWRP to be flashed with stock).
I usually do it from a command window opened in the TWRP folder (Shift-RightClick), like this:
Code:
adb reboot-bootloader
Now you are in fastbootmode.
Code:
fastboot boot twrp-3.1.0-athene_shreps.img
Of course, replace the TWRP name with "twrp-3.0.2-r4-athene.img" if that's is what you have.
In TWRP screen now:
1. Select MOUNT and check the System partition. Go back.
2. Select ADVANCED>TERMINAL
You have a # prompt. If not, type SU.
3. Type the following two lines in that terminal:
Code:
mv /system/etc/hosts /system/etc/hosts.bak
This renames the existing hosts file to hosts.bak . Not really needed... but better safer than sorry.
Code:
[COLOR="Blue"]ln -s /data/hosts /system/etc/hosts[/COLOR]
This creates a symbolic link to a location that AdAway can write.
Reboot and enjoy.
Simply copy that hosts file via any root Explorer
Sent from my Moto G4 Plus using Tapatalk
Hari Haran said:
Simply copy that hosts file via any root Explorer
Sent from my Moto G4 Plus using Tapatalk
Click to expand...
Click to collapse
This thing won't directly happen, imo:
SoNic67 said:
Code:
ln -s /data/hosts /system/etc/hosts
This creates a symbolic link to a location that AdAway can write.
Reboot and enjoy.
Click to expand...
Click to collapse
Hari Haran said:
Simply copy that hosts file via any root Explorer
Click to expand...
Click to collapse
Yeah, but you have to do it manually every time you update the hosts (AdAway update). Annoying IMO.
Thanks
Wow it worked great after a reboot. Is it like a hosts shortcut in etc folder to hosts file in data folder?
This needs to be re-done after the 93.14-4 security update.
I am running Stock, ElementalX, rooted with SuperSU.
I installed AdAway 3.2, checked systemless mode in the settings and that's it.
I am still at version 3.1.2. Thanks for the heads up.

Can't edit hosts file

Can't edit hosts file on mi note 10 rooted with magisk.
Read-only system.
Can't edit with root file manager or adb push from PC
Should I be trying to edit /system/etc/hosts file or /etc/hosts file

Categories

Resources