adb commands reference

You can issue adb commands from a command line on your development machine or from a script.

adb [-d | -e | -s serial_number] command

If there\'s only one emulator running or only one device connected, the adb command is sent to that device by default. If multiple emulators are running and/or multiple devices are attached, you need to use the -d, -e, or -s option to specify the target device to which the command should be directed.

The table below lists all of the supported adb commands and explains their meaning and usage.

Global options

Listen on all network interfaces instead of only on localhost.

adb -a

Direct an adb command to the only attached USB device. Returns an error when more than one USB device is attached.

adb -d

Direct an adb command to the only running emulator. Returns an error when more than one emulator is running.

adb -e

Direct an adb command to a specific device, referred to by its adb-assigned serial number (such as emulator-5556). Overrides the serial number value stored in the $ANDROID_SERIAL environment variable.

adb -s serial_number

The name of the adb server host. The default value is localhost.

adb -H server

The adb server port number. The default value is 5037.

adb -P port

Listen on the provided adb server socket. The default value is tcp:localhost:5037.

adb -L socket

General commands

Print a list of all devices. Use the -l option to include the device descriptions.

adb devices [-l]

Print a list of supported adb commands and their descriptions.

adb help

Print the adb version number.

adb version

Run commands on a device as an app (specified using package_name). This lets you run commands in adb as if the app you specify is running the command (that is, you have the same device access that the app has), without requiring root access. This might be necessary when using adb on a non-rooted device or an emulator with a Play Store image. The app must be debuggable.

adb run-as package_name

Networking commands

Connect to a device over TCP/IP. If you do not specify a port, then the default port, 5555, is used.

adb connect host[:port]

Disconnect from the specified TCP/IP device running on the specified port. If you do not specify a host or a port, then all devices are disconnected from all TCP/IP ports. If you specify a host, but not a port, the default port, 5555, is used.

adb disconnect [host | host:port]

List all forwarded socket connections.

adb forward --list

Forward socket connections from the specified local port to the specified remote port on the device. You can specify both local and remote ports in the following ways:

adb forward [--no-rebind]  local  remote

Remove the specified forwarded socket connection.

adb forward --remove local

List all reverse socket connections from the device.

adb reverse --list

Reverse a socket connection. The --no-rebind option means the reversal fails if the specified socket is already bound through a previous reverse command. You can specify the port for both local and remote arguments in the following ways:

adb reverse [--no-rebind] remote  local

Remove the specified reverse socket connection from the device.

adb reverse --remove remote

Remove all reverse socket connections from the device.

adb reverse --remove-all

File transfer commands

Copy files and directories from the local device (computer) to a remote location on the device.

adb push local remote

Copy remote files and directories to a device. Use the -a option to preserve the file time stamp and mode.

adb pull [-a] remote local

Synchronize a local build from the location specified in $ANDROID_PRODUCT_OUT to the device. All changed files are copied from the specified partition. The default is to sync all partitions. This command is only used when you build the Android platform source. App developers don’t need to use this command.

The $ANDROID_PRODUCT_OUT environment variable is automatically set by the Android build system to contain the location of the system images. Normally you won't need to set $ANDROID_PRODUCT_OUT when doing adb sync, but it can be useful if you're not in a build tree (but have one) or are syncing between build trees without switching between them.

adb sync
adb sync  [system|vendor|oem|data|all]

App installation commands

Push packages to the device and install them. Possible options are the following:

adb install [options] package

Same options as install with the addition of the following:

adb install-multiple [options]  packages

Remove this app package from the device. Add the -k option to keep the data and cache directories.

adb uninstall [-k] package

Backup and restore commands

Write an archive of the device's data to file. If you do not specify a file name, the default file is backup.adb. The package list is optional when you specify the -all and -shared options. The following describes the usages for the other options:

adb backup` \[`-f file`\] \[`-apk` | `-noapk`\] \[`-obb` | `-noobb`\] \[`-shared` | `-noshared`\] \[`-all`\] \[`-system` | \[`-nosystem`\] `package_names

Restore the device contents from file.

adb restore file

Debug commands

Print a bugreport to the specified path. If path is a directory, then the bug report is saved to that directory using the default file name, Devices that do not support zipped bug reports print to stdout.

adb bugreport path

Print a list of the available JDWP processes on a given device. Use forward jdwp:pid to connect to a specific JDWP process. For example:

adb jdwp

Print log data to the screen.

The $ADB_TRACE environment variable contains a comma-separated list of the debug information to log. Values can be any combination of the following: all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, and jdwp.

adb logcat [-help] [option] [filter-spec]

Security commands

Disable dm-verity checking on userdebug builds. The dm-verity option ensures that when a user boots a device that it is in the same state that it was in when it was last used.

adb disable-verity

Re-enable dm-verity checking on userdebug builds. The dm-verity option ensures that when a user boots a device that it is in the same state that it was in when it was last used.

adb enable-verity

Generate adb public and private RSA encrypted keys. The private key is stored in file. The public key is stored in An RSA key pair is needed when you use adb to connect over USB for the first time. You must accept the host computer's RSA key to explicitly grant adb access to the device.

Use the $ANDROID_VENDOR_KEYS environment variable to point to a file or directory that contains 2048-bit RSA authentication key pairs that you generated with the keygen command. These key pairs are in addition to the RSA key pairs generated by the adb server.

When the adb server needs a key, it first searches the adb server key store directory. If no keys are found, it then checks the $ANDROID_VENDOR_KEYS environment variable for a location. If still no keys are found, the local adb server generates and saves a new key pair in the adb server key store directory. For this reason, only an OEM creating a new Android device should need to run 'adb keygen' themselves.

By default key pairs generated by the adb server are stored in the following key store directories as adbkey (private key) and (public key):

adb keygen file

Scripting commands

Wait for the device to be in the specified state.

adb wait-for [-transport] -state

Print the adb state of a device. The adb state can be print offline, bootloader, or device.

adb get-state

Print the adb device serial number string.

adb get-serialno

Print the adb device path.

adb get-devpath

Remount the /system, /vendor, and /oem partitions in read-write mode.

adb remount

Reboot the device. This command defaults to booting the system image, but also supports bootloader and recovery.

adb reboot [bootloader | recovery | sideload | sideload-auto-reboot ]

Side load (install in APK format) the specified full OTA package onto the device.

adb sideload otapackage

Restart adbd with root permissions.

adb root

Restart adbd without root permissions.

adb unroot

Restart the adb server listening on USB.

adb usb

Restart the adb server listening on TCP at the specified port.

adb tcpip port-number

Internal debugging commands

Check whether the adb server process is running.

adb start-server

Terminate the adb server process.

adb kill-server

Force a reconnect from the host.

adb reconnect

Force a reconnect from the device to force a reconnect.

adb reconnect device

Shell commands

Start a remote interactive shell in the target device.

adb shell

Issue a shell command in the target device and then exit the remote shell. Use any combination of the following options:

adb shell -e escape_char [-n] [-T] [-t] [-x] [command]

Run an emulator console command

adb emu command