Skip to content

参考文档:

ADB常用命令

Android 系统是基于Linux内核的,所以Linux里的很多命令在Android里也有相同或类似的实现,在adb shell里可以调用。

shell
#刷机命令
adb reboot recovery                                #重启到 Recovery 模式
adb reboot                                         #从 Recovery 重启到系统
adb reboot bootloader                              #重启到 Fastboot 模式
adb sideload update.zip                            #开启 sideload 后刷入ROM

#基本命令
adb devices                                        #列出连接的设备
adb connect [ip]                                   #连接设备
adb disconnect [ip]:[端口]                         #断开已连接的设备
adb -s [主机id] [shell命令]                         #只在某一主机执行命令
adb kill-server                                    #关闭adb
adb tcpip 5555                                     #先通过usb连接开启无线调试,若无线连接失败,可能是目标设备没有开启无线调试

#设置代理
adb shell settings put global http_proxy IP:端口
#清除代理
adb shell settings delete global global_http_proxy_host
adb shell settings delete global global_http_proxy_port
adb shell settings delete global http_proxy

adb install xxx.apk                                #安装软件
adb shell pm list packages                         #查看应用列表
adb shell dumpsys package <apkname>                #查看软件的Activity
adb uninstall [-k] com.example.myapp               #卸载软件([-k]表示保留软件数据)
adb push <local_file_path> <device_file_path>      #向手机推送文件
adb pull <device_file_path> <local_file_path>      #取出手机的文件
adb logcat -f /sdcard/1.txt                        #将日志导出到手机储存中的1.txt
adb shell screencap -p /sdcard/1.png               #截图保存为手机储存中的1.png
adb shell screenrecord /sdcard/1.mp4               #屏幕录制保存到手机储存中的1.mp4  

adb shell am start 包名/Activity类名                #启动软件
adb shell am stopservice [options]                 #停止软件
adb shell pm disable-user <apkname>                #禁用软件
adb shell pm enable <apkname>                      #启用用软件
adb shell am force-stop                            #强制停止软件
adb shell getprop ro.product.model                 #查看设备型号
adb shell dumpsys battery                          #查看设备电量
adb shell wm size                                  #查看设备分辨率
adb shell wm density                               #查看设备dpi
adb shell ifconfig                                 #查看设备网络信息
adb shell cat /proc/cpuinfo                        #查看设备cpu信息
adb shell cat /proc/meminfo                        #查看设备内存信息

Fastboot常用命令

shell
fastboot devices                                    #列出连接的设备
fastboot reboot                                     #重启设备
fastboot reboot-<xxx模>                           #重启到对应模式
fastboot oem device-info                            #查看设备bl锁状态
fastboot oem unlock / fastboot flashing unlock      #解除bl锁
fastboot oem lock / fastboot flashing lock          #上bl锁

fastboot update xxx.zip                             #升级系统(卡刷包)
fastboot flash 分区 xxxx.img                         #刷写分区
fastboot erase 分区                                  #擦除分区
fastboot format cache                                #清除cache分区
fastboot format userdata                             #清除userdata分区
fastboot boot kernel.img ramdisk.gz                  #刷入kernel.img
fastboot flash:raw boot kernel.img ramdisk.gz        #提取kernel.img