Adb Shell Commands Cheat Sheet



ADB, Android Debug Bridge, is a command-line utility included with Google's Android SDK. ADB can control your device over USB from a computer, copy files back and forth, install and uninstall apps, run shell commands, and more. Using ADB and ADB Shell commands, we can perform various actions on a device. In order that you can execute ADB and Fastboot commands, the Android SDK Platform-tools package must be installed on your Windows, Linux, or macOS computer. In this article, we’ll explore a huge list of ADB Shell commands list with a cheat sheet. It won't be the first one nor the last cheat sheet on this. Open a shell: adb shell. You will use the Android SDK tools through the command line, for example. Notebooks also support a few auxiliary magic commands:%sh: Allows you to run shell code in your notebook. To fail the cell if the shell command has a non-zero exit status, add the -e option. This command runs only on the Apache Spark driver, and not the workers. To run a shell command on all nodes, use an init script. Adb shell setprop How do I find ADB located Download the latest version of the platform-tools (about 8 MB), If you installed Android Studio (Android SDK), the default path is C: Users YOUR-NAME AppData Local Android Sdk in Windows.

General Commands¶

CommandsDescription
adb tcpip 5555
adb connect device_ip_address
adb connect host:port # if port not given then default port is 5555
To connect a device over wifi
# connect device via usb and enter first command, after that disconnect device and enter second command in terminal
adb kill-serverReset adb host
adb start-serverRestart adb server and daemon after above command
adb forward tcp:6100 tcp:7100
adb forward tcp:6100 local:logd
Set up arbitrary port forwarding, which forwards requests on a specific host port to a different port on a device
Adb devices -lList of attached devices in detail
Adb install [option] path_to_apkInstall an app into device
Options:
-l: forward lock app
-r: raplace existing package
-t: allow test packages
-s: install on sd card
-d: allow version code downgrade
-g: grant all runtime permissions
adb uninstall [-k] packageReamove app, -k option is to keep the data and cache directories
adb pull remote localcopy data from device to host machine
adb push local remoteCopy data from host machine to device
emulator -avd emulator_name -port 5555connect a pre-made emulator to port 5555
adb -s device_adb_code commandexecute command on a specific device if multiple are connected
adb -d command # device
adb -e command # emulator
if device and emulator both are connected
adb backup [option] package_nameBackup phone apps data into PC
Options:
1. -f file_name: if file_name not given then backup.adb
2. -apk / -noapk: backup apk file also, default is -noapk
3. -obb / -noobb: backup obb file or not, -noobb is default
4. -shared / -noshared: backup shared storage or not
5. -all: backup app apps, package_name not required
6. -system / -nosystem: default is -system
adb restore file_namerestore data from backed up data file
adb bugreport pathDefault filename is bugreport.zip, devices that do not support zipped bug reports print to stdout
adb logcat [-help] [-option] [filter-spec]
adb reboot [bootloader / recovery / sideload / sideload-auto-reboot]Reboot device in specified mode
adb get-serialnoPrint the adb device serial number string
adb shellStart a remote interactive shell in the target device
adb shell am [command]Activity Manager
Options:
1. start -a intent: Start an activity specified by intent
#adb shell am start -a android.intent.action.VIEW
2. startservice [option] intent: start a service specified by an intent
3. force-stop package: force stop everything associated with package
4. kill-all: kill all background processes
5. profile start process file: start profiler on process, write result to file
6. profile stop process: stop profiler on process
7. display-size [reset / w*h]: override display size
8. display-density new_dpi: override display density
adb shell dpm commanddevice policy manager
adb shell screencap /sdcard/screen.pngTake a screenshot of device display
adb shell screenrecord [option] /sdcard/demo.mp4Stop the screen recording by pressing Control + C; otherwise, the recording stops automatically at three minutes or the time limit set by --time-limit
Options:
--help: Help
--size w*h: default is 1280*720 if supported by device
--bit-rate rate: in megabits per second (4Mbps -> enter value 4000000)
--time-limit time: time limit in seconds. default is 180
--verbose: display log information
adb shell dmesgPrint kernel debugging message to screen
adb shell sqlite3 /path_in_device/file_name.dbstart sqlite3 command line program

Package Manager¶

Adb Shell Commands Cheat Sheet Cheat

adb shell pm [command]

Adb Shell Commands Cheat Sheet
CommandsDescription
list packages [option] filterPrints all packages, optionally only those whose package name contains the text in filter
Options:
-f: see their associated files
-d: filter to only show disabled packages
-e: show enabled packages
-s: show system packages
-3: show third party packages
-i: see the installer for the packages
-u: include uninstalled packages
--user uid: user space to query
list permission-groupsprint all known permission groups
list permission [option] groupPrint all known permissions, optionally only those in groups
Options:
-g: organized by group
-f: print all information
-s: short summary
-d: list dangerous permissions
-u: list only the permissions users will see
list featuresPrint all features
list librariesLibraries supported by current device
list usersall users on the system
path packagePath to apk of the given package
clear packagedelete all data associated to package
grant package permissionGrant a permission to an app
revoke package permissionRevoke a permission from an app
set-install location locationChange the default install location
Options:
0: auto, let the system decide
1: internal
2: external
get-install-locationreturn current default install location
create-user user_nameCreate new user # supported in multi-user devices only
remove-user uidRemove user with given user_id and data associated with them
get-max-usersRemove user with given user_id and data associated with them
Adb shell commands cheat sheet

Include adb and other android tools on your path

In Users/hugomatilla.bash_profile addexport PATH=$PATH:/Users/hugomatilla/Documents/AndroidSDKs/sdk/platform-toolsexport PATH=$PATH:/Users/hugomatilla/Documents/AndroidSDKs/sdk/tools

Adb Shell Commands

My own adb location

Commands

Kill server

Start server

Sends files to device

Retreive files from device

List all packages

Uninstall

Install

List all connected devices

Clear data

URI

Adb Shell Commands Cheat Sheet 2019

Mime Type and and Extra string

Activity

Activity with extras

Service

Broadcast with Action

Notification

Commands

TABLES

SCHEMA

QUERY

HELP

Allow Computer Keyboard