How to Use Android ADB Command Line Tool
Android Debug Bridge (adb) is a tool that lets you manage the state of an emulator instance or Android phone. ADB is bundled with Android SDK package that can be downloaded from Android SDK download page. This tool is usefull for communicating with Android phone such as install application, copy files from/to device and perform some linux shell commands.
How to Install
Download and install Java SDK (Ex:jdk-6u20-windows-i586.exe)
Download Android SDK package (Ex:android-sdk_r06-windows.zip)
Extract SDK package into anywhere on your drive (Ex: D:\android-sdk-windows)
Phone Setup
In order to use ADB, you have to enable USB Debugging option in phone settings (Settings->Applications->Development)
How to Use
- Connect the phone to your pc/notebook usb port
- Run Windows command line tool (cmd) and go to D:\android-sdk-windows\tool
Update!!
New Android SDK puts adb executable file on \platform-tools directory instead of tool. So the path should be D:\android-sdk-windows\platform-tools
Usefull Commands
1. Check connected phone
Syntax: adb devices
2. Login to Android shell
Syntax: adb shell
Note:
If you get ‘#’ after typing adb shell, you are already get root access on the phone, no need to type su. Otherwise if you get ‘$’ , type ‘su’ to get root access (only for rooted device).
3. Some usefull shell commands
- ls
List directory
Syntax: ls [path]
Example:
#ls /system/lib
- cp
Copy file or directory
Syntax: cp [options] source dest
Note:
To copy or delete files in Android root directories you have to change the directory access mode to ‘read and write (rw)’ using command: remount rw
Example:
#remount rw
#cp /sdcard/libsec-ril.so /system/lib
#remount ro
- mv
Move file or directory
Syntax: mv [options] source dest
Example:
#mv /system/lib/libsec-ril.so /sdcard/backup
- chmod
Change file/directory permission
Syntax: chmod [-R] mode[,mode] …. file
Example:
#chmod 0644 /system/lib/libsec-ril.so
- rm
Remove file or directory
Syntax: rm [options] file
Example:
#rm /system/lib/libsec-ril.so
4. Install application
You can use adb to install aplication from your local drive into phone.
Syntax: adb install appname.apk
Example:
D:\android-sdk-windows\tools\adb install D:\AnReboot.apk
5. Copy files from phone to local drive
Syntax: adb pull source [destination]
Example:
D:\android-sdk-windows\tools\adb pull /sdcard/arm11-dvm.zip
D:\android-sdk-windows\tools\adb pull /sdcard/arm11-dvm.zip D:\
6. Copy files from local drive to phone
Syntax: adb push source destination
Example:
D:\android-sdk-windows\tools\adb push D:\AnReboot.apk /sdcard
To See The Original Link Please Click Here
获取序列号:
adb get-serialno
查看连接计算机的设备:
adb devices
重启机器:
adb reboot
重启到bootloader,即刷机模式:
adb reboot bootloader
重启到recovery,即恢复模式:
adb reboot recovery
查看log:
adb logcat
终止adb服务进程:
adb kill-server
重启adb服务进程:
adb start-server
获取机器MAC地址:
adb shell cat /sys/class/net/wlan0/address
获取CPU序列号:
adb shell cat /proc/cpuinfo
安装APK:
adb install //比如:adb install baidu.apk
保留数据和缓存文件,重新安装apk:
adb install -r //比如:adb install -r baidu.apk
安装apk到sd卡:
adb install -s // 比如:adb install -s baidu.apk
卸载APK:
adb uninstall //比如:adb uninstall com.baidu.search
卸载app但保留数据和缓存文件:
adb uninstall -k //比如:adb uninstall -k com.baidu.search
启动应用:
adb shell am start -n /.
查看设备cpu和内存占用情况:
adb shell top
查看占用内存前6的app:
adb shell top -m 6
刷新一次内存信息,然后返回:
adb shell top -n 1
查询各进程内存使用情况:
adb shell procrank
杀死一个进程:
adb shell kill [pid]
查看进程列表:
adb shell ps
查看指定进程状态:
adb shell ps -x [PID]
查看后台services信息:
adb shell service list
查看当前内存占用:
adb shell cat /proc/meminfo
查看IO内存分区:
adb shell cat /proc/iomem
将system分区重新挂载为可读写分区:
adb remount
从本地复制文件到设备:
adb push
从设备复制文件到本地:
adb pull
列出目录下的文件和文件夹,等同于dos中的dir命令:
adb shell ls
进入文件夹,等同于dos中的cd 命令:
adb shell cd
重命名文件:
adb shell rename path/oldfilename path/newfilename
删除system/avi.apk:
adb shell rm /system/avi.apk
删除文件夹及其下面所有文件:
adb shell rm -r
移动文件:
adb shell mv path/file newpath/file
设置文件权限:
adb shell chmod 777 /system/fonts/DroidSansFallback.ttf
新建文件夹:
adb shell mkdir path/foldelname
查看文件内容:
adb shell cat
查看wifi密码:
adb shell cat /data/misc/wifi/*.conf
清除log缓存:
adb logcat -c
查看bug报告:
adb bugreport
获取设备名称:
adb shell cat /system/build.prop
查看ADB帮助:
adb help
跑monkey:
adb shell monkey -v -p your.package.name 500
访问数据库SQLite3
adb shell
sqlite3
How to Use Android ADB Command Line Tool的更多相关文章
- Cordova 3.0 Plugin 安装 及"git" command line tool is not installed
根据http://docs.phonegap.com/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface Windows命令行 ...
- JMeterPluginsCMD Command Line Tool
There is small command-line utility for generating graphs out of JTL files. It behave just like righ ...
- Cookies with curl the command line tool
w https://curl.haxx.se/docs/http-cookies.html curl has a full cookie "engine" built in. If ...
- android adb command
一.adb启动activity: $ adb shell$ am start -n {包(package)名}/{包名}.{活动(activity)名称} 如:启动浏览器 # am start -n ...
- xcode10对应的xcode command line tool编译的坑
众所周知,xcode10新增的编译系统new build system会不支持一些老项目的编译,一般的做法是在Xcode编译配置Xcode->File->Project Settings/ ...
- NSRunLoop 在mac command line tool上的部分运用
首先RunLoop相关博客参考这篇https://blog.csdn.net/lengshengren/article/details/12905627. 最近开发了一个mac上的命令行工具,我在主线 ...
- [Android ADB] An auto-input method for Android and Windows
The Valentine's Day is coming. Here is an auto-input method and you may use it to send multiple word ...
- cURL POST command line on WINDOWS RESTful service
26down votefavorite 7 My problem: Running windows 7 and using the executable command line tool to cu ...
- Building Xcode iOS projects and creating *.ipa file from the command line
For our development process of iOS applications, we are using Jenkins set up on the Mac Mini Server, ...
随机推荐
- WebGL入门教程(三)-webgl动画
前面文章: WebGL入门教程(一)-初识webgl WebGL入门教程(二)-webgl绘制三角形 WebGL动画有移动.旋转和缩放,我们将移动.旋转和缩放图形,然后将其绘制到屏幕上,称为变换(tr ...
- 查看Linux系统版本与位数
查看系统发行版信息 查看LSB (Linux Standard Base)本身的版本信息. .el5 .el5 .el5 -bit LSB executable, Intel 80386, ver ...
- ListAdapter列表适配器
ListAdapter列表适配器其实是继承了BaseAdapter 示例图: MainActivity package com.shaoxin.mylistadapter; import androi ...
- Linux学习笔记(13)-进程通信|命名管道
匿名管道只能在具有亲属关系的进程间通信,那么如果想要在不具有亲戚关系,想在陌生人之间通信,那又该怎么办呢? 别慌,Linux身为世界上*强大的操作系统,当然提供了这种机制,那便是命名管道-- 所谓命名 ...
- Visual Studio 禁用Resharpe插件
和普通的插件不一样,对于Resharper7+版本需要使用启动参数:/Resharper.Suspend
- ODAC (odp.net) 从开发到部署
2013-09-30 16:08 4097人阅读 评论(0) 收藏 举报 分类: Oracle(10) 版权声明:本文为博主原创文章,未经博主允许不得转载. 1. 确定你开发机和服务器的操作系统是 ...
- asp.net dataset 判断是否为空 ?
1,if(ds == null) 这是判断内存中的数据集是否为空,说明DATASET为空,行和列都不存在!! 2,if(ds.Tables.Count == 0) 这应该是在内存中存在一个DATASE ...
- php备份数据库
php备份数据库原理和方法 原理 查找所有表 查找所有字段,列出所有字段名 字段类型等信息 查找所有数据 读取后注意特殊符号转换addslashes() 生成sql 把数据库格式化生成对应sql 相关 ...
- C# 完整List例子
C# List Following examples show how to create and manipulate with .NET strongly typed list List<T ...
- Python使用总结二
近来因为工作需要,用Python比较多,写得多了,收获也多.借此记录总结一下,方便以后反思. 一.IDE的选择 1.notepad++加上cmd窗口 前些时候写python脚本都用notepad++编 ...