adb
Debug and interact with Android devices
TLDR
Check whether the adb server process is running and start it
Terminate the adb server process
Start a remote shell in the target emulator/device instance
Push an Android application to an emulator/device
Copy a file/directory from the target device
Copy a file/directory to the target device
List all connected devices
Specify which device to send commands to if there are multiple devices
SYNOPSIS
adb [options] command [arguments]
PARAMETERS
-a
Listen on all network interfaces (not just localhost)
-d
Use first USB-connected device (fails if multiple)
-e
Use first emulator (fails if multiple)
-s SERIAL
Use device with specified serial number (overrides $ANDROID_SERIAL)
-t ID
Use device with given transport ID
-H HOSTNAME
ADB server host [default: localhost]
-P PORT
ADB server port [default: 5037]
-L SOCKET
Listen on local socket instead of /dev/socket/adb
-R TCPPORT
Delegate to existing ADB server on given TCP port
DESCRIPTION
The adb (Android Debug Bridge) is a versatile command-line tool included in the Android SDK Platform-Tools. It acts as a bridge between a development machine and Android devices or emulators, enabling a wide range of interactions.
Key functionalities include:
• Listing connected devices with adb devices.
• Executing shell commands via adb shell.
• Transferring files using adb push and adb pull.
• Installing/uninstalling apps with adb install.
• Forwarding ports, taking screenshots, recording screen, and debugging apps.
ADB operates over USB or TCP/IP, supporting multiple devices via serial numbers. It starts an ADB server daemon on the host, which communicates with adbd on the device. USB debugging must be enabled in device settings. Essential for Android development, testing, and automation.
Install via Android SDK or package managers like apt (android-tools-adb). Runs on Linux, macOS, Windows.
CAVEATS
Requires USB debugging enabled on device; USB drivers needed for some hardware.
Security risks if misused (e.g., root access via exploits).
Multiple devices require -s flag; server restart with 'adb kill-server'.
Not for production use without precautions.
COMMON SUBCOMMANDS
adb devices: List devices.
adb shell: Run remote shell.
adb push/pull local remote: File transfer.
adb install APK: Install app.
adb logcat: View logs.
adb forward tcp:PORT tcp:PORT: Port forwarding.
SERVER MANAGEMENT
adb start-server: Start daemon.
adb kill-server: Stop daemon.
adb version: Show version.
HISTORY
Developed by Google as part of Android SDK (circa 2007). Evolved with Android versions; now open-source under Apache 2.0. Key updates include Wi-Fi support (2010s), transport IDs for multi-device handling.
SEE ALSO
fastboot(8)


