ADB (Android Debug Bridge) Commands
Discover a comprehensive collection of ADB commands for Android debugging and development. Learn how to manage variables, execute general commands, control network settings, and utilize miscellaneous functions with ADB.
Variables
| Variable | Description |
|---|---|
$ADB_TRACE | Comma-separated list of debug info to log |
$ADB_VENDOR_KEYS | Colon-separated list of keys (files or directories) |
$ANDROID_SERIAL | Serial number to connect to (see -s) |
$ANDROID_LOG_TAGS | Tags to be used by logcat (see logcat --help for more) |
$ADB_LOCAL_TRANSPORT_MAX_PORT | Max emulator scan port (default 5585, 16 emus) |
$ADB_MDNS_AUTO_CONNECT | Comma-separated list of mdns services to allow auto-connect |
General Commands
Create bugreport.zip in /sdcard path
adb bugreport /sdcard
List pids of processes hosting a JDWP transport
adb jdwp
Show device log
adb logcat
Sideload the given full OTA package
adb sideload OTAPACKAGE
Restart adbd with root permissions
adb root
Restart adbd without root permissions
adb unroot
Restart adbd listening on USB
adb usb
Restart adbd listening on TCP on PORT
adb tcpip <port>
Restart userspace
adb reboot userspace
Start adb server
adb start-server
Kill adb server
adb kill-server
Stop adb server
adb stop-server
Kick connection from host side to force reconnect
adb reconnect
Kick connection from device side to force reconnect
adb reconnect device
Reset offline/unauthorized devices to force reconnect
adb reconnect offline
Attach a detached USB device
adb attach
Detach from a USB device to allow use by other
adb detach
Enter device shell
adb shell
Choose escape character, or "none"; default '~'
adb shell -e
Don't read from stdin
adb shell -n
Disable pty allocation
adb shell -T
Allocate a pty if on a tty
adb shell -t
Force allocate a pty if on a tty
adb shell -tt
Disable remote exit codes and stdout/stderr separation
adb shell -x
Run emulator console command
adb shell emu COMMAND
Enter device shell when there is more than one device connected
Enter the device shell when there is more than one device connected.
- USB connected:
adb -s <serial> shell
- Network connected:
adb -s <ip:port> shell
Print connection status
adb devices -l
Print current adb version installed
adb version
Network Commands
Connect to a device via TCP/IP
- Default port: 5555
adb connect <ip:port>
Disconnect all connected devices
adb disconnect all
Disconnect from the given TCP/IP device
adb disconnect <ip:port>
Pair with a device for secure TCP/IP communication
adb pair <ip:port> <pairing code>
List all forward socket connections
adb forward --list
Forward socket connection
- Port 0 = Any port
adb forward tcp:8080 tcp:8080
adb forward localabstract:<socket name>
adb forward localreserved:<socket name>
adb forward localfilesystem:<socket name>
adb forward jdwp:<process pid> (remote only)
adb forward vsock:<CID>:<port> (remote only)
adb forward acceptfd:<fd> (listen only)
Remove a specific forward socket connection
adb forward --remove 'local/remote'
Remove all forward socket connections
adb forward --remove-all
Run PPP over USB
adb ppp TTY <parameter>
List all reverse socket connections
adb reverse --list
Reverse socket connection using
adb reverse tcp:<port>
adb reverse localabstract:<socket name>
adb reverse localreserved:<socket name>
adb reverse localfilesystem:<socket name>
Remove a specific reverse socket connection
adb reverse --remove 'LOCAL/REMOTE'
Remove all reverse socket connections
adb reverse --remove-all
Check if mdns discovery is available
adb mdns check
List all discovered services
adb mdns services
Miscellaneous Commands
Disable dm-verity checking on userdebug builds
adb disable-verity
Re-enable dm-verity checking on userdebug builds
adb enable-verity
Generate adb public/private key
adb keygen <filename>
Print device state
adb get-state
Print device serial number
adb get-serialno
Print the device path
adb get-devpath
Remount partitions read-write
adb remount -R