Using adb
Table of Contents
1. Mental Model
Host-side adb interacts with the phone through a host-side adb server and a client-side adbd daemon. The daemon interacts with the server through either USB ot TCP.
2. Usage
First, connect the phone to computer through USB cables. Then running adb devices will list all connected devices. The -l argument lists more information.
$ adb devices
# List of devices attached
# 3B661600A7A00000 unauthorized
$ adb devices -l
# List of devices attached
# 3B661600A7A00000 unauthorized usb:3-1.4 transport_id:1
If there’s only one device connected, we can directly run adb shell to enter the shell to interact with the phone. Otherwise, we should specify which device to connect through -s <code>:
$ adb shell # if single device
$ adb -s <code> shell
# if multiple devices, for example, '3B661600A7A00000' above.
After entering the shell, we can operate as if it’s an ordinary Linux system.
Sometimes, we may also need to transfer files from host to phone. We can do this through adb push <local> <remote>. To grep a file from phone, we can use adb pull <remote> <local>.
$ adb push <local> <remote>
$ adb pull <remote> <local>