ADB Usage Complete
ADB Usage Complete
doanpt / awesome-adb
forked from lixiaogang03/awesome-adb
MIT License
Star Watch
master
View code
README.md
Awesome Adb
https://github.com/doanpt/awesome-adb 1/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Continuously updated, feel free to mention PR and Issue supplementary correction, you can
find useful this GitHub repository Star Collection spare.
Note: The support of some commands may be related to the Android system version and
the implementation of custom ROM.
Table of Contents
Basic usage
Command syntax
Specify the target device for the command
turn stop
View adb version
Run adbd with root privileges
Specify the network port of the adb server
Device connection management
Query connected devices/emulators
USB connection
Wireless connection (requires USB cable)
Wireless connection (no need to use USB cable)
Application management
View application list
All apps
system applications
third-party usage
Applications whose package name contains a certain string
Install APK
Uninstall app
Clear app data and cache
View foreground activity
View running services
View application details
View application installation path
Interact with the application
Start the application / call up Activity
https://github.com/doanpt/awesome-adb 2/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Transfer Service
Stop Service
Send broadcast
Force application to stop
Tighten memory
File management
Copy the files in the device to the computer
Copy files from computer to device
Analog button/input
Power button
menu
HOME key
return key
volume control
Media control
Turn on/off the screen
Slide to unlock
Input text
View log
Android log
Filter logs by level
Filter logs by tag and level
Log format
Clear log
Kernel log
View device information
model
Battery condition
Screen Resolution
Screen density
Display parameters
android_id
IMEI
Android system version
IP address
Mac address
CPU information
Memory information
https://github.com/doanpt/awesome-adb 3/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
https://github.com/doanpt/awesome-adb 4/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Basic usage
Command syntax
The basic syntax of the adb command is as follows:
parameter meaning
$ adb devices
For example, at this time you want to specify cf264b8f the device to run adb command to
get the screen resolution:
https://github.com/doanpt/awesome-adb 5/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Another example would like to 10.129.164.6:5555 mount the device to the application (
this form of serialNumber format <IP>:<Port> , typically a wireless device or the like
connected to third Genymotion Android emulator ):
In the case of multiple devices/simulators, these parameters are used to specify the
target device for the command. The following is a simplified description and will not
be repeated.
turn stop
Start the adb server command:
adb start-server
(Generally, there is no need to manually execute this command. If you find that the adb
server is not started when running the adb command, it will be automatically activated.)
adb kill-server
adb version
Sample output:
https://github.com/doanpt/awesome-adb 6/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
So if adbd ordinary permission to perform, some need root privileges to execute the
command can not be directly adb xxx executed. Then you can adb shell then
su commands have been executed, but also allows adbd executed with root privileges, this
will be able to execute arbitrary commands a higher authority.
command:
adb root
Normal output:
Now run adb shell , take a look at the command line prompt is not into # it?
After some phone can not root through adb root let adbd executed with root privileges,
such as some models of Samsung, will command prompt adbd cannot run as root in
production builds , then you can install adbd Insecure, then adb root try.
Accordingly, if you want to restore adbd non-root privileges, you can use the adb
unroot command.
adb devices
Sample output:
https://github.com/doanpt/awesome-adb 7/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
emulator-5554 device
10.129.164.6:5555 device
The output format is [serialNumber] [state] serialNumber, which is what we often call
SN, and the state is as follows:
device —— The device is connected. Note that this state does not indicate that the
Android system has been fully started and operable. The device instance can be
connected to adb during the device startup process, but the system will be in an
operable state after startup.
The output shows a three devices currently connected / simulator cf264b8f , emulator-
5554 and 10.129.164.6:5555 respectively their SN. From emulator-5554 this it can be
seen that the name is an Android emulator, and 10.129.164.6:5555 this form of <IP>:
<Port> the device or the like is generally serialNumber Genymotion wirelessly connected to
third Android emulator.
USB connection
To use adb normally through USB connection, you need to ensure several points:
Including the Android device is in a normal boot state, the USB cable and various
interfaces are intact.
2. Developer options and USB debugging mode for Android devices are turned on.
https://github.com/doanpt/awesome-adb 8/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
If you can't find the developer option in the settings, you need to use an easter egg to
show it: click the "version number" 7 times in "Settings"-"About Phone".
It seems that you don’t need to worry about this under Linux and Mac OS X. Under
Windows, you may encounter a situation where you need to install a driver. To confirm
this, you can right-click "Computer"-"Properties" and go to the "Device Manager" to
view related devices Whether there is a yellow exclamation mark or question mark, if
not, it means the drive status is good. Otherwise, you can download a mobile assistant
program to install the driver first.
4. Confirm the status after connecting the computer and the device via the USB cable.
adb devices
xxxxxx device
Steps:
1. Connect the Android device and the computer to run adb to the same local area
network, for example to the same WiFi.
Make sure the connection is successful (can be run adb devices to see if the device is
listed).
https://github.com/doanpt/awesome-adb 9/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Generally "Settings" in - "About phone" - "state information" - "IP address" found below
where you can use to view the device information - IP address of a way to see inside
with adb command.
Here <device-ip-address> is the IP address of the device found in the previous step.
adb devices
If you can not connect, verify that Android devices and computers are connected to the
same WiFi, then execute again adb connect <device-ip-address> that step;
If that does not work, by adb kill-server then all over again to try to restart the adb.
command:
The previous section "Wireless connection (requires USB cable)" is the method introduced
in the official document, which requires the help of a USB data cable to achieve wireless
connection.
Since we want to achieve wireless connection, can all steps be wireless? The answer is
yes.
Devices that have already been installed can skip this step. The download address of
the terminal emulator I use is: Terminal Emulator for Android Downloads
2. Connect the Android device and the computer to run adb to the same local area
network, for example to the same WiFi.
3. Open the terminal emulator on the Android device and run the commands in sequence:
su
setprop service.adb.tcp.port 5555
Generally "Settings" in - "About phone" - "state information" - "IP address" found below
where you can use to view the device information - IP address of a way to see inside
with adb command.
5. Connect the Android device via adb and IP address on the computer.
Here <device-ip-address> is the IP address of the device found in the previous step.
Section Note 1:
Some devices, such as Xiaomi 5S + MIUI 8.0 + Android 6.0.1 MXB48T, may need to restart
the adbd service before step 5, and run on the device's terminal emulator:
restart adbd
stop adbd
start adbd
Application management
https://github.com/doanpt/awesome-adb 11/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
adb shell pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [--user USER_ID]
That adb shell pm list packages can be added on the basis of a number of different
parameters to filter to view a list of supported filter parameters are as follows:
no All apps
All apps
command:
Sample output:
package:com.android.smoketest
package:com.example.android.livecubes
package:com.android.providers.telephony
package:com.google.android.googlequicksearchbox
package:com.android.providers.calendar
package:com.android.providers.media
package:com.android.protips
package:com.android.documentsui
package:com.android.gallery
package:com.android.externalstorage
...
// other packages here
...
https://github.com/doanpt/awesome-adb 12/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
system applications
command:
third-party usage
command:
For example, to view the package name that contains the string mazhuang application list,
the command:
Install APK
Command format:
parameter:
adb install Some optional parameters can be followed to control the behavior of
installing APK. The available parameters and their meanings are as follows:
parameter meaning
https://github.com/doanpt/awesome-adb 13/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
parameter meaning
After running the command, if you see output similar to the following (the status is
Success ), the installation is successful:
[100%] /data/local/tmp/1.apk
pkg: /data/local/tmp/1.apk
Success
The above is the output of the current latest version v1.0.36 of adb, which will display the
progress percentage of the push apk file to the phone.
[100%] /data/local/tmp/map-20160831.apk
pkg: /data/local/tmp/map-20160831.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]
Common installation failure output codes, meanings and possible solutions are as follows:
Output meaning
https://github.com/doanpt/awesome-adb 14/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Output meaning
It is a test-only applicatio
INSTALL_FAILED_TEST_ONLY did not specify the instal
t parameters
https://github.com/doanpt/awesome-adb 15/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Output meaning
1. It cannot be installed
specified location;
2. The application signa
INSTALL_FAILED_INVALID_INSTALL_LOCATION
consistent with the ROM
signature and is regarde
built-in application.
Installation location is no
INSTALL_FAILED_MEDIA_UNAVAILABLE
available
Inconsistent expectation
INSTALL_FAILED_PACKAGE_CHANGED
between application and
https://github.com/doanpt/awesome-adb 16/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Output meaning
Unresolved AndroidMan
INSTALL_PARSE_FAILED_BAD_MANIFEST
file
No or invalid package na
INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME
the manifest file
https://github.com/doanpt/awesome-adb 17/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Output meaning
https://github.com/doanpt/awesome-adb 18/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Output meaning
No device successfully
error: device not found
connected
Installation to sdcard is n
Unknown option: -s
supported under Android
signatures do not match the previously installed version; The app is already insta
ignoring! the signature is inconsis
Reference: PackageManager.java
Therefore, when necessary, you can also follow this step to manually perform the
installation process step by step.
Uninstall app
command:
https://github.com/doanpt/awesome-adb 19/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Command example:
<packagename> Represents the application name package. The effect of this command is
equivalent to clicking "Clear Cache" and "Clear Data" on the application information
interface in the settings.
Command example:
Sample output:
In the Windows command above may not be available, you can try adb shell dumpsys
activity activities | findstr mResumedActivity or adb shell "dumpsys activity
activities | grep mResumedActivity" .
<packagename> Do not have to give the complete package name, such as running adb
shell dumpsys activity services org.mazhuang , then the package name
org.mazhuang.demo1 , org.mazhuang.demo2 and org.mazhuang123 other related Services
will be listed.
The output contains a lot of information, including Activity Resolver Table, Registered
ContentProviders, package name, userId, path to file resource code after installation,
version information, permission information and grant status, signature version information,
etc.
Sample output:
Registered ContentProviders:
org.mazhuang.guanggoo/com.tencent.bugly.beta.utils.BuglyFileProvider:
Provider{7a3c394 org.mazhuang.guanggoo/com.tencent.bugly.beta.utils.BuglyF
ContentProvider Authorities:
[org.mazhuang.guanggoo.fileProvider]:
Provider{7a3c394 org.mazhuang.guanggoo/com.tencent.bugly.beta.utils.BuglyF
applicationInfo=ApplicationInfo{7754242 org.mazhuang.guanggoo}
https://github.com/doanpt/awesome-adb 21/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Packages:
Package [org.mazhuang.guanggoo] (c1d7f):
userId=10394
pkg=Package{55f714c org.mazhuang.guanggoo}
codePath=/data/app/org.mazhuang.guanggoo-2
resourcePath=/data/app/org.mazhuang.guanggoo-2
legacyNativeLibraryDir=/data/app/org.mazhuang.guanggoo-2/lib
primaryCpuAbi=null
secondaryCpuAbi=null
versionCode=74 minSdk=15 targetSdk=25
versionName=1.1.74
splits=[base]
apkSigningVersion=2
applicationInfo=ApplicationInfo{7754242 org.mazhuang.guanggoo}
flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP]
privateFlags=[ RESIZEABLE_ACTIVITIES]
dataDir=/data/user/0/org.mazhuang.guanggoo
supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity]
timeStamp=2017-10-22 23:50:53
firstInstallTime=2017-10-22 23:50:25
lastUpdateTime=2017-10-22 23:50:55
installerPackageName=com.miui.packageinstaller
signatures=PackageSignatures{af09595 [53c7caa2]}
installPermissionsFixed=true installStatus=1
pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP]
requested permissions:
android.permission.READ_PHONE_STATE
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_WIFI_STATE
android.permission.READ_LOGS
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_EXTERNAL_STORAGE
install permissions:
android.permission.INTERNET: granted=true
android.permission.ACCESS_NETWORK_STATE: granted=true
android.permission.ACCESS_WIFI_STATE: granted=true
User 0: ceDataInode=1155675 installed=true hidden=false suspended=false st
gids=[3003]
runtime permissions:
android.permission.READ_EXTERNAL_STORAGE: granted=true
android.permission.READ_PHONE_STATE: granted=true
android.permission.WRITE_EXTERNAL_STORAGE: granted=true
User 999: ceDataInode=0 installed=false hidden=false suspended=false stopp
gids=[3003]
runtime permissions:
Dexopt state:
[org.mazhuang.guanggoo]
Instruction Set: arm64
path: /data/app/org.mazhuang.guanggoo-2/base.apk
status: /data/app/org.mazhuang.guanggoo-2/oat/arm64/base.odex [compilati
te]
https://github.com/doanpt/awesome-adb 22/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Sample output:
package:/data/app/ecarx.weather-1.apk
Mainly the use of am <command> the command, commonly used <command> as follows:
command use
<INTENT> The parameters are very flexible and correspond to the Intent in the code when
writing the Android program.
parameter meaning
-a
Specify action, such as android.intent.action.VIEW
<ACTION>
-c
Specify category, such as android.intent.category.APP_CONTACTS
<CATEGORY>
https://github.com/doanpt/awesome-adb 23/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
<INTENT> It can also carry data, just like Bundle when writing code:
parameter meaning
--es <EXTRA_KEY>
`-e
<EXTRA_STRING_VALUE>`
--ecn <EXTRA_KEY>
component name
<EXTRA_COMPONENT_NAME_VALUE>
Command format:
E.g:
https://github.com/doanpt/awesome-adb 24/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Start without specifying the Activity name (start the main Activity)
Command format:
E.g:
Transfer Service
Command format:
E.g:
Another typical use case is if the virtual button should be displayed on the device but not
displayed, you can try this:
Stop Service
Command format:
Send broadcast
Command format:
https://github.com/doanpt/awesome-adb 25/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
This type of usage is very practical when testing. For example, a broadcast scene is difficult
to create. You can consider sending broadcasts in this way.
It can send the pre-defined broadcast of the system and also send the self-defined
broadcast. The following is part of the system predefined broadcast and normal trigger
timing:
https://github.com/doanpt/awesome-adb 26/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Command example:
Means to stop all the processes and services of 360 Security Guard.
Tighten memory
command:
https://github.com/doanpt/awesome-adb 27/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Command example:
File management
Which 电脑上的⽬录 parameters can be omitted, copy the default to the current directory.
example:
* Tips: * file path on the device may need root privileges to access, if your equipment has
been root, you can use adb shell and su the command to obtain root privileges in adb
shell, the first cp /path/on/device /sdcard/filename copy files to sdcard, then adb pull
/sdcard/filename /path/on/pc .
adb push < file path on computer > < directory in device >
example:
https://github.com/doanpt/awesome-adb 28/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
* Tips: * file path common permissions on the device may not be directly written to, if your
device has root before, you can first adb push /path/on/pc /sdcard/filename , then adb
shell and su after obtaining root privileges in adb shell where cp /sdcard/filename
/path/on/device .
Analog button/input
In the adb shell inside there is a very useful command is called input , through which
you can do some interesting things.
Usage: input [ < source > ] < command > [ < arg > ...]
For example, use adb shell input keyevent <keycode> the command, different keycode
can perform different functions, a complete list of keycode see KeyEvent , I think the
interesting part of the quote is as follows:
keycode meaning
3 HOME key
4 return key
https://github.com/doanpt/awesome-adb 29/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
keycode meaning
26 Power button
64 Open browser
82 menu
85 play / Pause
86 Stop play
122 Move the cursor to the beginning of the line or the top of the list
123 Move the cursor to the end of the line or the bottom of the list
164 Mute
https://github.com/doanpt/awesome-adb 30/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
keycode meaning
Power button
command:
menu
command:
HOME key
command:
return key
command:
volume control
Increase volume:
https://github.com/doanpt/awesome-adb 31/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Mute:
Media control
play / Pause:
Stop play:
Resume playback:
Pause playback:
https://github.com/doanpt/awesome-adb 32/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Slide to unlock
If no password lock screen is unlocked by sliding gestures, you can input swipe unlock.
Command (parameters are based on model Nexus 5, slide up gesture to unlock example):
Parameters 300 1000 300 500 , respectively 起始点x坐标 起始点y坐标 结束点x坐标 结束点y坐
标 .
Input text
When the focus is in a text box, you can input enter text commands.
command:
View log
The Android system log is divided into two parts. The underlying Linux kernel log is output
to /proc/kmsg, and the Android log is output to /dev/log.
Android log
Command format:
[adb] logcat [ < option > ] ... [ < filter-spec > ] ...
https://github.com/doanpt/awesome-adb 33/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Filtering logs by a certain level will output logs of that level and above.
adb logcat * :W
( Note: In macOS need to give *:W this order * as the tag parameter double quotation
marks, such as adb logcat "*:W" , or will be error no matches found: *:W .)
It means to output the ActivityManager log of the Info level above the tag, output the log
MyApp of the Debug level above the tag, and the Silent level log of other tags (that is, shield
other tag logs).
Log format
You can use adb logcat -v <format> the output format option to specify a log.
brief
< priority > / < tag >( < pid > ) : < message >
https://github.com/doanpt/awesome-adb 34/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Example:
process
Example:
tag
Example:
raw
Example:
time
< datetime > < priority > / < tag >( < pid > ) : < message >
Example:
https://github.com/doanpt/awesome-adb 35/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
threadtime
< datetime > < pid > < tid > < priority > < tag > : < message >
Example:
long
[ < datetime > < pid > : < tid > < priority > / < tag > ]
< message >
Example:
The specified format can be used simultaneously with the above filtering. such as:
Clear log
adb logcat -c
Kernel log
command:
Sample output:
https://github.com/doanpt/awesome-adb 36/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
< 6 > [14201.684016] PM: noirq resume of devices complete after 0.982 msecs
< 6 > [14201.685525] PM: early resume of devices complete after 0.838 msecs
< 6 > [14201.753642] PM: resume of devices complete after 68.106 msecs
< 4 > [14201.755954] Restarting tasks ... done.
< 6 > [14201.771229] PM: suspend exit 2016-08-28 13:31:32.679217193 UTC
< 6 > [14201.872373] PM: suspend entry 2016-08-28 13:31: 32.780363596 UTC
< 6 > [14201.872498] PM: Syncing filesystems ... done.
By kernel log we can do something, such as a measure of the kernel boot time, found in the
kernel log after the system is ready in Freeing init memory front of the line that time is.
model
command:
Sample output:
Nexus 5
Battery condition
command:
Input example:
https://github.com/doanpt/awesome-adb 37/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
temperature: 280
technology: Li-poly
Which scale represents the maximum power, level represents the current charge. The
output above indicates that 44% of the battery is left.
Screen Resolution
command:
Sample output:
Indicates that the screen resolution of the device was originally 1080px * 1920px, but is
currently modified to 480px * 1024px.
Screen density
command:
Sample output:
https://github.com/doanpt/awesome-adb 38/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Indicates that the screen density of the device was originally 480dpi, but is currently
modified to 160dpi.
Display parameters
command:
Sample output:
Which mDisplayId is the display number init is the initial resolution and screen density
and app height than init in the smaller, expressed the virtual keys at the bottom of the
screen, height is 1920 - 1794 = 126px co 42dp.
android_id
command:
Sample output:
51b6be48bac8c569
IMEI
In Android 4.4 and below, IMEI can be obtained by the following command:
Sample output:
https://github.com/doanpt/awesome-adb 39/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
In Android 5.0 and above, the output of this command is empty, and it has to be obtained by
other means (root permission is required):
adb shell
su
service call iphonesubinfo 1
Sample output:
Result: Parcel(
0x00000000: 00000000 0000000f 00360038 00390030 ' ........8.6.0.9. '
0x00000010: 00350035 00320030 00370037 00350038 ' 5.5.0.2.7.7.8.5. '
0x00000020: 00340030 00000031 ' 0.4.1... ' )
Extracting the effective content inside is IMEI, for example, here is 860955027785041 .
Reference: adb shell dumpsys iphonesubinfo not working since Android 5.0 Lollipop
Sample output:
5.0.2
IP address
Every time you want to know the IP address of the device, you have to "Settings"-"About
Phone"-"Status Information"-"IP Address" is annoying, right? It can be easily viewed
through adb.
command:
Sample output:
https://github.com/doanpt/awesome-adb 40/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
This command has no output on some devices. If the device is connected to WiFi, you can
use the following command to view the LAN IP:
Sample output:
or
If the above command still does not get the expected information, you can try the following
command (available in some system versions):
Sample output:
https://github.com/doanpt/awesome-adb 41/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
You can see information such as network connection name, activation status, IP address,
and Mac address.
Mac address
command:
Sample output:
f8:a9:d0:17:42:4d
This view is the LAN Mac address, mobile network connection, or other information that
may be mentioned by an earlier section "IP address" in adb shell netcfg order to see.
CPU information
command:
Sample output:
processor : 1
BogoMIPS : 38.40
processor : 2
BogoMIPS : 38.40
processor : 3
BogoMIPS : 38.40
https://github.com/doanpt/awesome-adb 42/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva
CPU implementer : 0x51
CPU architecture: 7
CPU variant : 0x2
CPU part : 0x06f
CPU revision : 0
This is the CPU information of Nexus 5. We can see from the output that the hardware used
is Qualcomm MSM 8974 , the processor number is 0 to 3, so it is quad-core, and the
architecture used is ARMv7 Processor rev 0 (v71) .
Memory information
command:
Sample output:
MemTotal: 1027424 kB
MemFree: 486564 kB
Buffers: 15224 kB
Cached: 72464 kB
SwapCached: 24152 kB
Active: 110572 kB
Inactive: 259060 kB
Active(anon): 79176 kB
Inactive(anon): 207736 kB
Active(file): 31396 kB
Inactive(file): 51324 kB
Unevictable: 3948 kB
Mlocked: 0 kB
HighTotal: 409600 kB
HighFree: 132612 kB
LowTotal: 617824 kB
LowFree: 353952 kB
SwapTotal: 262140 kB
SwapFree: 207572 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 265324 kB
Mapped: 47072 kB
Shmem: 1020 kB
Slab: 57372 kB
https://github.com/doanpt/awesome-adb 43/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
SReclaimable: 7692 kB
SUnreclaim: 49680 kB
KernelStack: 4512 kB
PageTables: 5912 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 775852 kB
Committed_AS: 13520632 kB
VmallocTotal: 385024 kB
VmallocUsed: 61004 kB
VmallocChunk: 209668 kB
Among them, MemTotal is the total memory of the device, which MemFree is the current
free memory.
This will output a lot of information, including the "model" and "Android system version"
mentioned in the previous sections.
Further comprising output in some other useful information, they can adb shell getprop <
属性名> view the command alone, include a portion of the following properties:
Attribute name meaning
ro.product.model model
ro.product.brand Brand
https://github.com/doanpt/awesome-adb 44/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Section Note 1:
Some small factories custom ROM may be modified CPU support list of property names
abi, if the ro.product.cpu.abilist find can not attribute name, you can try this:
Sample output:
ro.product.cpu.abi=armeabi-v7a
ro.product.cpu.abi2=armeabi
Modify settings
Note: After modifying the settings, it is possible to run the restore command displays still
not normal, you can run adb reboot restart the device, or manual restart.
The principle of modifying settings is mainly to modify the setting values stored in
/data/data/com.android.providers.settings/databases/settings.db through the settings
command.
Resolution
command:
Screen density
command:
https://github.com/doanpt/awesome-adb 45/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Display area
command:
The four numbers respectively indicate the margin pixels from the left, top, right, and bottom
edges. The above command means to leave the bottom of the screen 200px blank.
restore:
It can't be restored by command, after all, if you turn off the USB debugging adb, you can't
connect to the Android device.
https://github.com/doanpt/awesome-adb 46/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
value meaning
Warning only-Allow access to all non-SDK interfaces, but keep the warning
1
information in the log, you can continue to use the strick mode API.
2 It is forbidden to call the interfaces in the dark gray list and black list.
It is forbidden to call the interfaces in the blacklist, but it is allowed to call the
3
interfaces in the dark gray list.
command:
<key-values> It can be composed of the following keys and their corresponding values in
the format <key1>=<value1>:<key2>=<value2> .
key meaning
immersive.preconfirms ?
https://github.com/doanpt/awesome-adb 47/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
The values corresponding to these keys can be combined with commas as the following
values:
value meaning
* All interfaces
E.g:
Indicates that the status bar and navigation bar are hidden at the same time in all
interfaces.
Representation provided in the package name com.package1 and com.package2 hide the
status bar in the application, in addition to a package named com.package3 all applications
hidden in the navigation bar.
Utility function
Screenshots
Save the screenshot to the computer:
If an older version of adb can not use exec-out command, this time recommended updates
adb version. If you cannot update, you can use the following troublesome methods:
https://github.com/doanpt/awesome-adb 48/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
You can use the adb shell screencap -h View screencap command help information,
here are two significant parameters and their meanings:
parameter meaning
-d display- Specify the screen number of the screenshot (when there are multiple
id screens)
If you specify the actual file name .png can be omitted -p parameter at the end; otherwise,
need to use the -p parameter. If you do not specify a file name, the content of the
screenshot file will be output directly to stdout.
Another way to take a screenshot of a one-line command and save it to the computer:
Mac OS X
This method requires the gnu sed command, which is available directly under Linux, and
also available under the bin folder of the Git installation directory under Windows. If you
really cannot find the command, you can download sed for Windows and add the folder
where sed.exe is located to the PATH environment variable.
However, using the sed command that comes with the system under Mac will report an
error:
Record screen
https://github.com/doanpt/awesome-adb 49/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Press when you need to stop Ctrl-C , the default recording time and maximum recording
time are both 180 seconds.
You can use the adb shell screenrecord --help View screenrecord command help
information, the following are common parameters and their meanings:
parameter meaning
--size The size of the video, for example 1280x720 , the default is the
WIDTHxHEIGHT screen resolution.
--bit-rate RATE The bit rate of the video, the default is 4Mbps.
The /system partition is mounted as read-only by default, but some operations such as
adding commands to the Android system and deleting its own applications require writing to
/system, so you need to remount it as read-write.
step:
command:
adb shell
su
command:
https://github.com/doanpt/awesome-adb 50/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
mount
Sample output:
3. Remount.
command:
If the output does not prompt an error, the operation is successful, and you can do whatever
you want with the files under /system.
https://github.com/doanpt/awesome-adb 51/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
command:
adb shell
su
cat /data/misc/wifi/ * .conf
Sample output:
network={
ssid= " TP-LINK_9DFC "
scan_ssid=1
psk= " 123456789 "
key_mgmt=WPA-PSK
group=CCMP TKIP
auth_alg=OPEN
sim_num=1
priority=13893
}
network={
ssid= " TP-LINK_F11E "
psk= " 987654321 "
key_mgmt=WPA-PSK
sim_num=1
priority=17293
}
ssid That is the name we see in the WLAN settings, psk the password, and key_mgmt the
security encryption method.
command:
adb shell
su
date -s 20160823.131500
Indicates to change the system date and time to 13:15:00 on August 23, 2016.
restart cellphone
https://github.com/doanpt/awesome-adb 52/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
command:
adb reboot
adb shell
su
At this point the command line prompt is $ said that no root privileges, is # it indicates root.
Simple usage:
Sometimes it is necessary to control the WiFi status of the device, which can be done with
the following commands.
Turn on WiFi:
adb root
adb shell svc wifi enable
adb root
adb shell svc wifi disable
https://github.com/doanpt/awesome-adb 53/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
If the execution is successful, the output will be empty; if the command is executed without
root privileges, the execution will fail and the output will be output Killed .
adb reboot
command:
2. Enter Apply update - on the Recovery interface of the device Apply from ADB .
Note: Different Recovery menus may be different from this, and some have first-level
menus Apply update from ADB .
https://github.com/doanpt/awesome-adb 54/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
command:
Enable/disable SELinux
Enable SELinux
adb root
adb shell setenforce 1
Disable SELinux
adb root
adb shell setenforce 0
Enable/disable dm_verity
Enable dm_verity
adb root
adb enable-verity
Disable dm_verity
adb root
adb disable-verity
Android system is based on the Linux kernel, so Linux in many commands in Android also
has the same or similar implement, in adb shell can be called in. Part earlier in this
document have been used in the adb shell command.
View process
command:
adb shell ps
https://github.com/doanpt/awesome-adb 55/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Sample output:
PID Process id
Sample output:
https://github.com/doanpt/awesome-adb 56/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Column
meaning
name
PID Process id
PR priority
#THR Threads
top The command also supports some command line parameters, the detailed usage is
as follows:
Such as:
https://github.com/doanpt/awesome-adb 57/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
2. After finding the pid of the corresponding process through the ps command adb shell
cat /proc/<pid>/status | grep Uid
Such as:
$ adb shell
gemini:/ $ ps | grep org.mazhuang.guanggoo
u0_a394 28635 770 1795812 78736 SyS_epoll_ 0000000000 S org.mazhuang.guang
gemini:/$ cat /proc/28635/status | grep Uid
Uid: 10394 10394 10394 10394
gemini:/$
other
The following is a brief description of other commonly used commands. The commands that
have been specifically mentioned above will not be explained separately:
command Features
cd Switch directory
rm Delete Files
common problem
https://github.com/doanpt/awesome-adb 58/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Possible Causes
Port 5037 that the adb server process wants to use is occupied.
solution
Find the process occupying port 5037, and then terminate it. Take Windows as an example:
...
TCP 0.0.0.0:5037 0.0.0.0:0 LISTENING 1548
...
Here 1548 is the process ID, end the process with the command:
com.android.ddmlib.AdbCommandRejectedException
Create a new emulator in Android Studio, but cannot connect with adb, prompt:
Install a terminal on the phone and execute su and prompt that there is no such command.
This is abnormal.
So after deleting the emulator, download and install it again, this time it is normal.
https://github.com/doanpt/awesome-adb 59/60
2/25/2021 doanpt/awesome-adb: ADB Usage Complete / ADB Usage Complete
Related commands
aapt
am
dumsys
pm
uiautomator
Thanks
Thank you friends for your selfless sharing and supplements (in no particular order).
Reference link
Releases
No releases published
Create a new release
Packages
No packages published
Publish your first package
https://github.com/doanpt/awesome-adb 60/60