android 主机模式_如何在Android(和阻止网站)上编辑主机文件

android 主机模式

android 主机模式

image

Whether you want to prevent your child from accessing Facebook or are simply sick of the advertisements that litter webpages, a custom hosts file can come in handy.

无论您是要阻止孩子访问Facebook,还是只是厌倦了乱扔垃圾网页的广告,都可以使用自定义托管文件。

Note: This requires a rooted Android device.

注意:这需要植根的Android设备。

如何在Android上编辑主机文件 (How to Edit the Hosts File on Android)

The easiest way to edit the hosts file on your device is to use the Android Debug Bridge, so go ahead and set it up. Once you’re done, navigate into the folder where ADB is located and type cmd into the location bar, which will open a command prompt in the current folder.

在设备上编辑主机文件的最简单方法是使用Android调试桥, 因此请继续进行设置 。 完成后,导航到ADB所在的文件夹,然后在位置栏中键入cmd,这将在当前文件夹中打开命令提示符。

image

Once the command prompt opens run the following command to see what devices are attached to your PC.

打开命令提示符后,运行以下命令以查看PC上连接了哪些设备。

adb devices

adb设备

image

Next you need to download the host file from your device so you can edit it.

接下来,您需要从设备下载主机文件,以便对其进行编辑。

adb pull /system/etc/hosts F:\hosts

亚行拉/ system / etc / hosts F:\ hosts

image

Then navigate to where you saved the file and open it with notepad.

然后导航到保存文件的位置,然后使用记事本打开它。

image

Now comes the fun part: adding the host entries. Really, you can do anything you want for example, you can use your host file to block ads from appearing on websites instead of using an app like AdBlocker, or in our case we can just block a website like FaceBook by redirecting it to localhost – you will have to search around to get the exact domains to block. When you’re done adding the entries don’t forget to save the file.

现在来了有趣的部分:添加主机条目。 确实,您可以做任何想做的事,例如, 您可以使用主机文件阻止广告在网站上展示,而不必使用AdBlocker之类的应用程序,或者在我们这种情况下,我们可以通过将FaceBook重定向到本地主机来阻止网站,例如–您将不得不四处搜索以获取要阻止的确切域。 完成添加条目后,别忘了保存文件。

image

Finally you will need ADB to push the file back to your device.

最后,您将需要ADB将文件推送回设备。

adb push F:\hosts /system/etc/

亚行推送F:\ hosts / system / etc /

image

That’s all there is to it. Now I can’t browse to Facebook from my device.

这里的所有都是它的。 现在,我无法从设备浏览到Facebook。

Screenshot_2013-03-11-20-19-34

翻译自: https://www.howtogeek.com/140576/how-to-edit-the-hosts-file-on-android-and-block-web-sites/

android 主机模式

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值