adb-shell
Access Android device's command-line shell
TLDR
Start a remote interactive shell on the emulator or device
Get all the properties from emulator or device
Revert all runtime permissions to their default
Revoke a dangerous permission for an application
Trigger a key event
Clear the data of an application on an emulator or device
Start an activity on emulator or device
Start the home activity on an emulator or device
SYNOPSIS
adb shell [options] [shellCommand]
PARAMETERS
-s
Target specific device by serial number
-d
Use USB-connected device only
-e
Use TCP/IP-connected device only
-t
Target specific transport ID
Command to execute remotely (interactive shell if omitted)
DESCRIPTION
The adb shell command is part of the Android Debug Bridge (ADB) toolset, allowing users to execute shell commands on a connected Android device or emulator from a host computer. ADB facilitates communication between a development machine and Android devices over USB or TCP/IP.
When invoked without arguments, adb shell launches an interactive shell session on the device, similar to a remote terminal. This enables navigation of the device's filesystem, running commands like ls, ps, or top, and performing administrative tasks.
Specifying a command after adb shell, such as adb shell ls /sdcard, executes that single command remotely and returns the output to the host. This is ideal for scripting and automation.
Key prerequisites include enabling USB debugging on the device (via Developer Options), installing ADB from the Android SDK Platform-Tools, and authorizing the host computer. Multiple devices are supported via the -s option. Security features like root access restrictions apply on production devices; custom recoveries like TWRP may offer elevated privileges.
Common use cases span debugging apps, inspecting logs, file management, and system diagnostics. Output mirrors the device's shell environment, typically based on Toybox or BusyBox.
CAVEATS
Requires USB debugging enabled and ADB authorized. Non-root shells have limited privileges. Interactive mode exits on Ctrl+D or exit. TCP mode needs prior adb tcpip. Daemon (adbd) must run on device.
EXAMPLES
adb shell (interactive shell)
adb shell getprop ro.build.version.release (check Android version)
adb -s emulator-5554 shell pm list packages (list apps on emulator)
SETUP
Download from developer.android.com/studio/releases/platform-tools. Add to PATH. Run adb devices to verify connection.
HISTORY
Introduced with Android SDK in 2007 by Google as part of AOSP. Evolved with Android versions; supports Wi-Fi ADB since Android 11+. Maintained in platform-tools package.


