Why need to change hosts file? Link to heading
Do you find yourself constantly checking your phone? Some websites like social media or youtube trigger compulsive behaviour and we end up spending valuable time. What is left in the end is only regret for wasting valuable time. Surem, we could install website blockers, but when the urge to check social media or flashy news websites is too strong, the easy way is to simply delete the blocking app and continue with the addiction. To make it harder to delete and independent from the fact whether we install third party software or not, we change the hosts
file on our android device. The hosts file is a local plain text file that maps servers or hostnames to IP addresses.
Prerequisites Link to heading
Smartphone with LineageOS installed. You can check if your phone is compatible here. If compatible, follow the respective guide to install the latest custom ROM from LineageOS. After clean install, proceed with the steps below.
- Go to Developer options and Enable USB debugging and Rooted debugging.
- Use USB cable to connect you phone to PC.
- Allow USB debugging connection in the phone screen popup.
- Check if device is connected.
adb devices
- Start adb in root mode.
adb root
- Pull the hosts file from phone. Location differs in various phones.
adb pull /system/etc/hosts
- Modify the
hosts
file according to your needs. - Remount the system in read/write mode to be able to write to it.
adb remount
- Push the modified hosts file to the phone.
adb push phone_hosts /system/etc/hosts
If you have any questions or queries then please feel free to drop me an email.