# What is ADB (Android Debug Bridge)?

**ADB (Android Debug Bridge)** is a versatile command-line tool used for interacting with Android devices (either physical devices or emulators) from a computer. It enables developers and security researchers to communicate with the device, perform various tasks like installing apps, debugging, and even accessing the underlying system shell.

## **ADB consists of three main components:**

1. **Client**: This is the command-line interface (CLI) or the terminal where commands are issued (i.e., your computer’s terminal or command prompt).
2. **Daemon (adbd)**: The background service running on the Android device, which listens for commands sent by the client. It allows the device to interact with the computer over a USB or wireless connection.
3. **Server**: This manages the communication between the client and the daemon. It facilitates connections to devices and handles multiple connections simultaneously.

## **How ADB Works:**

1. **Connection**: ADB communicates with devices either over a USB cable or wirelessly via IP (TCP/IP). You need to enable "Developer Options" and "USB Debugging" on the device for ADB to work.
2. **Commands**: Once connected, you can issue commands from the client (your computer) that will be executed on the device, allowing you to install apps, run shell commands, pull and push files, view logs, and much more.

## Some important ADB commands:

**1. adb --help**

* **Description**: Displays a list of available ADB commands with brief descriptions.
* **Example**: `adb --help` **2. adb devices -l**
* **Description**: Lists all connected devices with detailed information (like device model).
* **Example**: `adb devices -l` **3. adb connect \[IP\_address:port]**
* **Description**: Connects to a device over the network for wireless debugging.
* **Example**: `adb connect 192.168.0.100:5555` **4. adb disconnect \[IP\_address:port]**
* **Description**: Disconnects the device from ADB over the network.
* **Example**: `adb disconnect 192.168.0.100:5555` **5. adb shell**
* **Description**: Opens a command shell on the connected Android device to execute Linux commands.
* **Example**: `adb shell` **6. adb install \[path-to-apk]**
* **Description**: Installs an APK file on the connected device.
* **Example**: `adb install C:\\path\\to\\your\\app.apk` **7. adb uninstall \[package-name]**
* **Description**: Uninstalls an app based on its package name.
* **Example**: `adb shell pm uninstall com.example.app` **8. adb install -r \[path-to-apk]**
* **Description**: Replaces the existing app with a new version of the same app.
* **Example**: `adb install -r C:\\path\\to\\your\\app.apk` **9. adb root**
* **Description**: Grants root (superuser) access on the connected device (requires root privileges).
* **Example**: `adb root` **10. adb push \[local-file] \[remote-path]**
* **Description**: Copies a file from the local computer to the Android device.
* **Example**: `adb push C:\\test.txt /sdcard/` **11. adb pull \[remote-file] \[local-path]**
* **Description**: Copies a file from the Android device to the local computer.
* **Example**: `adb pull /sdcard/test.txt C:\\` **12. adb shell ps**
* **Description**: Lists the processes running on the Android device.
* **Example**: `adb shell ps` **13. adb shell pm list package | findstr \[keyword]**
* **Description**: Filters the installed packages based on a keyword (e.g., to find all ADB-related apps).
* **Example**: `adb shell pm list package | findstr adb` **14. adb shell screencap -p \[path-to-save-image]**
* **Description**: Takes a screenshot of the device and saves it to the specified path.
* **Example**: `adb shell screencap -p /sdcard/screenshot.png` **15. adb logcat --pid \[PID]**
* **Description**: Displays logs of a specific process by its process ID (PID).
* **Example**: `adb logcat --pid 1234` **16. adb shell am start -a android.intent.action.VIEW -d \[url]**
* **Description**: Opens the specified URL in the device’s default browser.
* **Example**: `adb shell am start -a android.intent.action.VIEW -d "<https://google.com>"` **17. adb shell am start \[package-name]/\[activity-name]**
* **Description**: Launches a specific activity from an app.
* **Example**: `adb shell am start io.hextree.reversingexample/.SecretActivity` **18. adb shell pm clear \[package-name]**
* **Description**: Clears the data of an installed app, effectively resetting it.
* **Example**: `adb shell pm clear com.example.app` **19. adb shell settings list system**
* **Description**: Lists the system settings on the Android device.
* **Example**: `adb shell settings list system` **20. adb shell dumpsys activity**
* **Description**: Provides detailed information about activities running on the device.
* **Example**: `adb shell dumpsys activity` **21. adb shell netstat**
* **Description**: Shows network connections on the device.
* **Example**: `adb shell netstat` **22. emulator -list-avds**
* **Description**: Lists all available Android Virtual Devices (AVDs) installed on your system.
* **Example**: `emulator -list-avds` **23. emulator -avd \[AVD\_name]**
* **Description**: Starts an emulator with the specified AVD (Android Virtual Device).
* **Example**: `emulator -avd Nexus_5X_API_27`
