ADB (Android Debug Bridge) is a console client-server program that acts as a universal interface for managing Android devices (or their emulators).

Through ADB programs on the computer, you can interact with your phone or tablet, for example, to synchronize contacts, backups of data or remotely access the device .

However, the main purpose of ADB is to debug applications and services during their development and testing. In this case, interaction with the device is performed through the console.

ADB Features:

  • viewing connected devices;
  • viewing logs;
  • copying files;
  • installing and uninstalling applications;
  • screenshots (and video recording) of the device screen;
  • deleting and flashing the data section;
  • launching various scripts;
  • management of network parameters.

There are three components to ADB:

  • a client that runs on a computer and sends commands. It can be invoked from the command line by entering the adb command;
  • a daemon that runs as a background process on an Android device and executes client commands;
  • a server that runs in the background on the computer and manages the client and daemon.

How ADB works:

  • at startup, the adb client checks for a running adb server process, and if not, launches it on the computer;
  • the server establishes a connection on port 5037 and listens to commands from adb clients on it;
  • the server then connects to all running devices by scanning odd ports in the 5555 to 5585 range. Each device uses a pair of serial ports — an even port for console connections, an odd numbered port for adb connections;
  • After the server has configured connections to devices, you can use adb commands to access them.

ADB Commands:-

  • adb devices – This is the command which is used to list all devices connected to the computer.
  • adb reboot – You can use this command to reboot your phone without using the power button. It can be used after modifications that require a reboot.
  • adb reboot bootloader – to use fastboot commands, you must first reboot the device into bootloader mode (fastboot or boot). the reboot bootloader command will do this.
  • adb reboot recovery – using this command you can boot your smartphone into recovery mode (recovery). The command will help those who do not know how to do this using the volume key combination of the power button.
  • adb shell – The shell command will enable the Linux terminal interface in your command window to control the connected Android device. This allows us to enter Linux commands to interact with the device.
  • adb install <path to file> – this command is designed to install applications to your device via your computer. Here <path to file> means the location and name of the installation APK file on the PC. To do this, by typing adb just drag the file to the command prompt window and the location along with the file name will be entered automatically.
  • adb install -t <path to file> – Like the above command, you can use this ADB command to install the application to the phone, but only to test it.
  • adb install -r <path to file> – if you want to reinstall the application on your smartphone or tablet, insert -r into the regular installation command.
  • adb install -f <path to file> – the application will be installed to the internal memory of the Android device.
  • adb shell pm uninstall com.example.myapp is an adb command to uninstall any existing apps on your smartphone or tablet. Here com.example.myapp refers to the package name of the app you want to uninstall. This is a useful command if you want to remove malware or preinstalled applications.
  • adb clear com.example.myapp – Will remove all data and cache related to the package.
  • adb shell screencap <screenshot location> – if you want to take a screenshot of your phone’s current screen, you can use this ADB command. Replace <screenshot location> with the location and name of the file where you want to save your screenshot, for example /sdcard/screenshot.png.
  • adb shell screenrecord <location of the screen recording file > – similar to the screenshot, you can also record a video of what is happening on the screen of a smartphone or tablet using the ADB command. Be sure to replace <screen recording location> with the location and extension where you want to save the screen recording file. For example, /storage/emulated/0/Download/screenrecord.mp4. To stop screen recording, press Ctrl + C.
  • adb push <file source> <destination> is an adb command used to copy <file source> from your computer to <destination> on your Android device.
  • adb pull <source> <destination> is the same command as adb push, but for copying files from phone to computer.
  • adb logcat – You can use this command to display the real-time log of your Android device.
  • adb logcat> logcat.txt – save the captured real-time log to the logcat.txt file.
  • adb remount – if the system partition of your phone is set to “Read Only”, but you want to mount it in “Read / Write” mode, then you can use this command.
  • adb sideload <file> – This adb command is used to upload any file to Android device. The file name must be complete with its extension.
  • adb kill-server is a command used to kill the adb process on the computer.
  • adb start-server – Restart the adb server after the process ends with the above command.
  • adb connect <device IP address> – to connect a phone with debugging access via WiFi.
  • adb forward tcp: 7100 tcp: 6100 is an ADB command to forward the host port from 7100 to 6100. Just replace the port number with another port that applies in your case.
  • adb –help – You can use this command to get help for the ADB program (ADB commands and so on).