| Fabien Sanglard | f2e342b | 2022-08-12 14:00:43 -0700 | [diff] [blame] | 1 | # ADB(1) MAN PAGE |
| 2 | |
| 3 | # VERSION |
| 4 | |
| 5 | 1.0.41 |
| 6 | |
| 7 | # NAME |
| 8 | |
| 9 | **adb** |
| 10 | CLI Client for ADB (Android Debug Bridge) Server. |
| 11 | |
| 12 | # SYNOPSIS |
| 13 | |
| 14 | **adb** [*GLOBAL_OPTIONS*] command [*COMMAND_OPTIONS*] |
| 15 | |
| 16 | # DESCRIPTION |
| 17 | |
| 18 | Connects to the ADB Server via its smart socket interface. Allows sending requests, receives responses and manages lifecycle of the adb server. |
| 19 | |
| 20 | Tasks are performed via commands. Some commands are fulfilled directly by the server while others are "forwarded over to the adbd(ADB daemon) running on the device. |
| 21 | |
| 22 | # GLOBAL OPTIONS: |
| 23 | |
| 24 | **-a** |
| 25 | Listen on all network interfaces, not just localhost. |
| 26 | |
| 27 | **-d** |
| 28 | Use USB device (error if multiple devices connected). |
| 29 | |
| 30 | **-e** |
| 31 | Use TCP/IP device (error if multiple TCP/IP devices available). |
| 32 | |
| 33 | **-s** **SERIAL** |
| 34 | Use device with given **SERIAL** (overrides $ANDROID_SERIAL). |
| 35 | |
| 36 | **-t** **ID** |
| 37 | Use device with given transport **ID**. |
| 38 | |
| 39 | **-H** |
| 40 | Name of adb server host [default=localhost]. |
| 41 | |
| 42 | **-P** **PORT** |
| 43 | Smart socket **PORT** of adb server [default=5037]. |
| 44 | |
| 45 | **-L** **SOCKET** |
| 46 | Listen on given socket for adb server [default=tcp:localhost:5037]. |
| 47 | |
| 48 | **\-\-one-device** **SERIAL**|**USB** |
| 49 | Server will only connect to one USB device, specified by a **SERIAL** number or **USB** device address (only with 'start-server' or 'server nodaemon'). |
| 50 | |
| 51 | **\-\-exit-on-write-error** |
| 52 | Exit if stdout is closed. |
| 53 | |
| 54 | |
| 55 | # GENERAL COMMANDS: |
| 56 | |
| 57 | devices [**-l**] |
| 58 | List connected devices. |
| 59 | |
| 60 | **-l** |
| 61 | Use long output. |
| 62 | |
| 63 | help |
| 64 | Show this help message. |
| 65 | |
| 66 | version |
| 67 | Show version number. |
| 68 | |
| 69 | # NETWORKING |
| 70 | |
| 71 | connect **HOST**[:**PORT**] |
| 72 | Connect to a device via TCP/IP [default **PORT**=5555]. |
| 73 | |
| 74 | disconnect [**HOST**[:**PORT**]] |
| 75 | Disconnect from given TCP/IP device [default **PORT**=5555], or all. |
| 76 | |
| 77 | pair **HOST**[:**PORT**] [**PAIRING_CODE**] |
| 78 | Pair with a device for secure TCP/IP communication. |
| 79 | |
| 80 | forward **\-\-list** | [**--no-rebind**] **LOCAL_REMOTE** | **\-\-remove** **LOCAL** | **\-\-remove-all** |
| 81 | |
| 82 | **\-\-list** |
| 83 | List all forward socket connections. |
| 84 | |
| 85 | [**--no-rebind**] **LOCAL_REMOTE** |
| 86 | Forward socket connection using one of the followings. |
| 87 | |
| 88 | **tcp**:**PORT** (local may be "tcp:0" to pick any open port. |
| 89 | **localreserved**:**UNIX_DOMAIN_SOCKET_NAME**. |
| 90 | **localfilesystem**:**UNIX_DOMAIN_SOCKET_NAME**. |
| 91 | **jdwp**:**PROCESS PID** (remote only). |
| 92 | **vsock**:**CID**:**PORT** (remote only). |
| 93 | **acceptfd**:**FD** (listen only). |
| 94 | |
| 95 | **\-\-remove** **LOCAL** |
| 96 | Remove specific forward socket connection. |
| 97 | |
| 98 | **\-\-remove-all** |
| 99 | Remove all forward socket connections. |
| 100 | |
| 101 | reverse **\-\-list** | [**\-\-no-rebind**] **REMOTE** **LOCAL** | **\-\-remove** **REMOTE** | **\-\-remove-all** |
| 102 | |
| 103 | **\-\-list** |
| 104 | List all reverse socket connections from device. |
| 105 | |
| 106 | [**\-\-no-rebind**] **REMOTE** **LOCAL** |
| 107 | Reverse socket connection using one of the following. |
| 108 | |
| 109 | tcp:**PORT** (**REMOTE** may be "tcp:0" to pick any open port). |
| 110 | localabstract:**UNIX_DOMAIN_SOCKET_NAME**. |
| 111 | localreserved:**UNIX_DOMAIN_SOCKET_NAME**. |
| 112 | localfilesystem:**UNIX_DOMAIN_SOCKET_NAME**. |
| 113 | |
| 114 | **\-\-remove** **REMOTE** |
| 115 | Remove specific reverse socket connection. |
| 116 | |
| 117 | **\-\-remove-all** |
| 118 | Remove all reverse socket connections from device. |
| 119 | |
| 120 | mdns **check** | **services** |
| 121 | Perform mDNS subcommands. |
| 122 | |
| 123 | **check** |
| 124 | Check if mdns discovery is available. |
| 125 | |
| 126 | **services** |
| 127 | List all discovered services. |
| 128 | |
| 129 | |
| 130 | # FILE TRANSFER: |
| 131 | |
| 132 | push [**--sync**] [**-z** **ALGORITHM**] [**-Z**] **LOCAL**... **REMOTE** |
| 133 | Copy local files/directories to device. |
| 134 | |
| 135 | **--sync** |
| 136 | Only push files that are newer on the host than the device. |
| 137 | |
| 138 | **-n** |
| 139 | Dry run, push files to device without storing to the filesystem. |
| 140 | |
| 141 | **-z** |
| 142 | enable compression with a specified algorithm (any/none/brotli/lz4/zstd). |
| 143 | |
| 144 | **-Z** |
| 145 | Disable compression. |
| 146 | |
| 147 | pull [**-a**] [**-z** **ALGORITHM**] [**-Z**] **REMOTE**... **LOCAL** |
| 148 | Copy files/dirs from device |
| 149 | |
| 150 | **-a** |
| 151 | preserve file timestamp and mode. |
| 152 | |
| 153 | **-z** |
| 154 | enable compression with a specified algorithm (**any**/**none**/**brotli**/**lz4**/**zstd**) |
| 155 | |
| 156 | **-Z** |
| 157 | disable compression |
| 158 | |
| 159 | sync [**-l**] [**-z** **ALGORITHM**] [**-Z**] [**all**|**data**|**odm**|**oem**|**product**|**system**|**system_ext**|**vendor**] |
| 160 | Sync a local build from $ANDROID_PRODUCT_OUT to the device (default all) |
| 161 | |
| 162 | **-n** |
| 163 | Dry run. Push files to device without storing to the filesystem. |
| 164 | |
| 165 | **-l** |
| 166 | List files that would be copied, but don't copy them. |
| 167 | |
| 168 | **-z** |
| 169 | Enable compression with a specified algorithm (**any**/**none**/**brotli**/**lz4**/**zstd**) |
| 170 | |
| 171 | **-Z** |
| 172 | Disable compression. |
| 173 | |
| 174 | # SHELL: |
| 175 | |
| 176 | shell [**-e** **ESCAPE**] [**-n**] [**-Tt**] [**-x**] [**COMMAND**...] |
| 177 | Run remote shell command (interactive shell if no command given). |
| 178 | |
| 179 | **-e** |
| 180 | Choose escape character, or "**none**"; default '**~**'. |
| 181 | |
| 182 | **-n** |
| 183 | Don't read from stdin. |
| 184 | |
| 185 | **-T**: |
| 186 | Disable pty allocation. |
| 187 | |
| 188 | **-t**: |
| 189 | Allocate a pty if on a tty (-tt: force pty allocation). |
| 190 | |
| 191 | **-x** |
| 192 | Disable remote exit codes and stdout/stderr separation. |
| 193 | |
| 194 | emu **COMMAND** |
| 195 | Run emulator console **COMMAND** |
| 196 | |
| 197 | # APP INSTALLATION |
| 198 | (see also `adb shell cmd package help`): |
| 199 | |
| 200 | install [**-lrtsdg**] [**--instant**] **PACKAGE** |
| 201 | Push a single package to the device and install it |
| 202 | |
| 203 | install-multiple [**-lrtsdpg**] [**--instant**] **PACKAGE**... |
| 204 | Push multiple APKs to the device for a single package and install them |
| 205 | |
| 206 | install-multi-package [**-lrtsdpg**] [**--instant**] **PACKAGE**... |
| 207 | Push one or more packages to the device and install them atomically |
| 208 | |
| 209 | **-r**: |
| 210 | Replace existing application. |
| 211 | |
| 212 | **-t** |
| 213 | Allow test packages. |
| 214 | |
| 215 | **-d** |
| 216 | Allow version code downgrade (debuggable packages only). |
| 217 | |
| 218 | **-p** |
| 219 | Partial application install (install-multiple only). |
| 220 | |
| 221 | **-g** |
| 222 | Grant all runtime permissions. |
| 223 | |
| 224 | **\-\-abi** **ABI** |
| 225 | Override platform's default ABI. |
| 226 | |
| 227 | **\-\-instant** |
| 228 | Cause the app to be installed as an ephemeral install app. |
| 229 | |
| 230 | **\-\-no-streaming** |
| 231 | Always push APK to device and invoke Package Manager as separate steps. |
| 232 | |
| 233 | **\-\-streaming** |
| 234 | Force streaming APK directly into Package Manager. |
| 235 | |
| 236 | **\-\-fastdeploy** |
| 237 | Use fast deploy. |
| 238 | |
| 239 | **-no-fastdeploy** |
| 240 | Prevent use of fast deploy. |
| 241 | |
| 242 | **-force-agent** |
| 243 | Force update of deployment agent when using fast deploy. |
| 244 | |
| 245 | **-date-check-agent** |
| 246 | Update deployment agent when local version is newer and using fast deploy. |
| 247 | |
| 248 | **\-\-version-check-agent** |
| 249 | Update deployment agent when local version has different version code and using fast deploy. |
| 250 | |
| 251 | **\-\-local-agent** |
| 252 | Locate agent files from local source build (instead of SDK location). See also `adb shell pm help` for more options. |
| 253 | |
| 254 | uninstall [**-k**] **APPLICATION_ID** |
| 255 | Remove this **APPLICATION_ID** from the device. |
| 256 | |
| 257 | **-k** |
| 258 | Keep the data and cache directories. |
| 259 | |
| 260 | # DEBUGGING: |
| 261 | |
| 262 | bugreport [**PATH**] |
| 263 | Write bugreport to given PATH [default=bugreport.zip]; if **PATH** is a directory, the bug report is saved in that directory. devices that don't support zipped bug reports output to stdout. |
| 264 | |
| 265 | jdwp |
| 266 | List pids of processes hosting a JDWP transport. |
| 267 | |
| 268 | logcat |
| 269 | Show device log (logcat --help for more). |
| 270 | |
| 271 | |
| 272 | # SECURITY: |
| 273 | |
| 274 | disable-verity |
| 275 | Disable dm-verity checking on userdebug builds. |
| 276 | |
| 277 | enable-verity |
| 278 | Re-enable dm-verity checking on userdebug builds. |
| 279 | |
| 280 | keygen **FILE** |
| 281 | Generate adb public/private key; private key stored in **FILE**. |
| 282 | |
| 283 | # SCRIPTING: |
| 284 | |
| 285 | wait-for [-**TRANSPORT**] -**STATE**... |
| 286 | Wait for device to be in a given state. |
| 287 | |
| 288 | **STATE**: device, recovery, rescue, sideload, bootloader, or disconnect. |
| 289 | **TRANSPORT**: **usb**, **local**, or **any** [default=**any**]. |
| 290 | |
| 291 | get-state |
| 292 | Print offline | bootloader | device. |
| 293 | |
| 294 | get-serialno |
| 295 | Print **SERIAL_NUMBER**. |
| 296 | |
| 297 | get-devpath |
| 298 | Print **DEVICE_PATH**. |
| 299 | |
| 300 | remount [**-R**] |
| 301 | Remount partitions read-write. |
| 302 | |
| 303 | **-R** |
| 304 | Automatically reboot the device. |
| 305 | |
| 306 | reboot [**bootloader**|**recovery**|**sideload**|**sideload-auto-reboot**] |
| 307 | Reboot the device; defaults to booting system image but supports **bootloader** and **recovery** too. |
| 308 | |
| 309 | **sideload** |
| 310 | Reboots into recovery and automatically starts sideload mode. |
| 311 | |
| 312 | **sideload-auto-reboot** |
| 313 | Same as **sideload** but reboots after sideloading. |
| 314 | |
| 315 | |
| 316 | sideload **OTAPACKAGE** |
| 317 | Sideload the given full OTA package **OTAPACKAGE**. |
| 318 | |
| 319 | root |
| 320 | Restart adbd with root permissions. |
| 321 | |
| 322 | unroot |
| 323 | Restart adbd without root permissions. |
| 324 | |
| 325 | usb |
| 326 | Restart adbd listening on USB. |
| 327 | |
| 328 | tcpip **PORT** |
| 329 | Restart adbd listening on TCP on **PORT**. |
| 330 | |
| 331 | # INTERNAL DEBUGGING: |
| 332 | |
| 333 | start-server |
| 334 | Ensure that there is a server running. |
| 335 | |
| 336 | kill-server |
| 337 | Kill the server if it is running. |
| 338 | |
| 339 | reconnect |
| 340 | Close connection from host side to force reconnect. |
| 341 | |
| 342 | reconnect device |
| 343 | Close connection from device side to force reconnect. |
| 344 | |
| 345 | reconnect offline |
| 346 | Reset offline/unauthorized devices to force reconnect. |
| 347 | |
| 348 | # USB: |
| 349 | |
| 350 | Only valid when running with libusb backend. |
| 351 | |
| 352 | attach **SERIAL** |
| 353 | Attach a detached USB device identified by its **SERIAL** number. |
| 354 | |
| 355 | detach **SERIAL** |
| 356 | Detach from a USB device identified by its **SERIAL** to allow use by other processes. |
| 357 | |
| 358 | |
| 359 | # ENVIRONMENT VARIABLES |
| 360 | |
| 361 | $ADB_TRACE |
| Fabien Sanglard | a354429 | 2023-07-21 20:24:20 +0000 | [diff] [blame] | 362 | Comma (or space) separated list of debug info to log: all,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwp. |
| Fabien Sanglard | f2e342b | 2022-08-12 14:00:43 -0700 | [diff] [blame] | 363 | |
| 364 | $ADB_VENDOR_KEYS |
| 365 | Colon-separated list of keys (files or directories). |
| 366 | |
| 367 | $ANDROID_SERIAL |
| 368 | Serial number to connect to (see -s). |
| 369 | |
| 370 | $ANDROID_LOG_TAGS |
| 371 | Tags to be used by logcat (see logcat --help). |
| 372 | |
| 373 | $ADB_LOCAL_TRANSPORT_MAX_PORT |
| 374 | Max emulator scan port (default 5585, 16 emulators). |
| 375 | |
| 376 | $ADB_MDNS_AUTO_CONNECT |
| 377 | Comma-separated list of mdns services to allow auto-connect (default adb-tls-connect). |
| 378 | |
| Fabien Sanglard | 0d1a7aa | 2023-07-25 06:06:16 +0000 | [diff] [blame^] | 379 | $ADB_MDNS_OPENSCREEN |
| 380 | The default mDNS-SD backend is Bonjour (mdnsResponder). For machines where Bonjour is not installed, adb can spawn its own, embedded, mDNS-SD back end, openscreen. If set to "1", this env variable forces mDNS backend to openscreen. |
| 381 | |
| Fabien Sanglard | f2e342b | 2022-08-12 14:00:43 -0700 | [diff] [blame] | 382 | # BUGS |
| 383 | |
| 384 | See Issue Tracker: [here](https://issuetracker.google.com/issues/new?component=192795&template=1310483). |
| 385 | |
| 386 | # AUTHORS |
| 387 | |
| 388 | See [OWNERS](../../OWNERS) file in ADB AOSP repo. |