用adb来修改android嵌入式设备的system只读目录下的东西

转的一篇:

以修改hosts文件为例:

由于某些原因,可能需要指定域名对应的IP地址。Android是基于Linux的系统,与Linux类似,通过hosts文件来设置。

在Android下,/etc是link到/system/etc的,我们需要修改/system/etc/hosts来实现。但是这个文件是只读,不能通过shell直接修改。可以通过连接到PC上使用adb来修改。步骤如下:

1、获得root权限:adb root

2、设置/system为可读写:adb remount

3、将hosts文件复制到PC:adb pull /system/etc/hosts <PC机上文件名>

4、修改PC机上文件

5、将PC机上文件复制到手机:adb push <PC机上文件名> /system/etc/hosts

如果要查看是否修改成功,可以在PC上执行adb shell,运行cat /system/etc/hosts;或者在手机上运行cat /system/etc/hosts。

原文地址:https://www.cnblogs.com/xmilt/p/10419528.html