This post is essentially dedicated to understand what Android Debug Bridge (adb) really is. How can we use it.
As we know Android has Linux kernel underneath. To execute a process via we need to provide corresponding command line command. Unless you root your android device you cannot really instal the terminal emulator application. The shell can be accessed via ADB (Android Debug Bridge) command tool.
To get the overview of ADB refer to following picture
Emulator 1, console: 5554
Emulator 1, adb: 5555
Emulator 2, console: 5556
Emulator 2, adb: 5557
and so on...
As shown, the emulator instance connected to adb on port 5555 is the same as the instance whose console listens on port 5554.
Once the server has set up connections to all emulator instances, you can use adb commands to access those instances. Because the server manages connections to emulator/device instances and handles commands from multiple adb clients, you can control any emulator/device instance from any client (or from a script).[Source]
As we know Android has Linux kernel underneath. To execute a process via we need to provide corresponding command line command. Unless you root your android device you cannot really instal the terminal emulator application. The shell can be accessed via ADB (Android Debug Bridge) command tool.
What is Android Debug Bridge?
Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an
emulator instance or connected Android-powered device.
It is a client-server program that includes
three components:
- A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
- A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.
- A daemon, which runs as a background process on each emulator or device instance.
To get the overview of ADB refer to following picture
Where can I find ADB tool utility?
More on ADB....
When you start an adb client, the client first checks whether there is an adb server
process already running. If there isn't, it starts the server process. When the server starts,
it binds to local TCP port 5037 and listens for commands sent from adb clients—all adb
clients use port 5037 to communicate with the adb server.
The server then sets up connections to all running emulator/device
instances. It locates emulator/device instances by scanning odd-numbered
ports in the range 5555 to 5585, the range used by emulators/devices.
Where the server finds an adb daemon, it sets up a connection to that
port. Note that each emulator/device instance acquires a pair of
sequential ports — an even-numbered port for console connections and an
odd-numbered port for adb connections. For example:
Emulator 1, console: 5554
Emulator 1, adb: 5555
Emulator 2, console: 5556
Emulator 2, adb: 5557
and so on...
As shown, the emulator instance connected to adb on port 5555 is the same as the instance whose console listens on port 5554.
Once the server has set up connections to all emulator instances, you can use adb commands to access those instances. Because the server manages connections to emulator/device instances and handles commands from multiple adb clients, you can control any emulator/device instance from any client (or from a script).[Source]
Usage Common Usage Examples
- adb device(shows all the devices with device id the adb server is connected to)
- adb help( Shows adb version and all possible commands)
- adb start-server(To start adb server if not started already)
- adb kill-server(To kill adb server)
- adb push <local> <remote>(To push a file from local machine to remote device/emulator)
- adb pull <remote> <local>(To get a file from remote device/emulator to local machine)
- adb version(Shows version number of adb running)
- adb reboot(Reboots the device)
- adb root(Restarts the adbd daemon with root priveledges)
- adb backup(Used to backup your device. You can backup everything with -all argument)
- adb restore (Restore from a backup taken earlier).
- adb install (Push and Install a package)
- adb uninstall (Uninstall a package)
- adb shell(get shell access to your Android device)
Note : How to completely backup your android device has been already covered in a previous post. You can go through that post.