How to Install Android Debug Bridge (adb) in Linux
Android Debug Bridge (adb) is the most used command-line tool that enables the communication between a personal computer and a connected Android-powered device or emulator instance over a USB cable or TCP/IP (wirelessly).
It supports various device actions such as networking, scripting, installing and debugging apps, and file transfer. It also provides access to a Unix shell that can be used to run a variety of Linux commands on a device.
adb is a client-server tool that includes three main components:
- a client that runs on your development machine and sends commands. You can execute it from a command line by running an adb command.
- a daemon (adbd) that runs as a background process on each device and executes commands on a device.
- a server that manages communication between the client and the daemon, it runs as a background process on your development machine.
The adb command-line tool ships with the standalone Android SDK Platform Tools package, a component of the Android SDK. Let’s look at how to grab and install the latest version of the Android SDK Platform Tools package in Linux.
Install Android Debug Bridge (adb) in Linux
To install the adb package, run the appropriate command for your Linux distributions, as follows:
$ sudo apt install adb [On Debian, Ubuntu and Mint] $ sudo yum install adb [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] $ sudo emerge -a dev-util/android-tools [On Gentoo Linux] $ sudo apk add adb [On Alpine Linux] $ sudo pacman -S android-tools [On Arch Linux] $ sudo zypper install adb [On OpenSUSE]
Note: If you wish to use the latest version of adb, move to the next section to download and set up the latest binary from the Android SDK Platform Tools package release.
Install Android SDK Platform Tools in Linux
You can download the most recent version of the Android SDK Platform command-line tools from the SDK Platform Tools release page. Alternatively, run the following commands to download the archived package, extract it, and move it into the extracted folder:
$ mkdir cli-tools $ wget -c https://dl.google.com/android/repository/platform-tools-latest-linux.zip $ unzip platform-tools-latest-linux.zip $ cd platform-tools/
After extracting the archive file, you can list the content of the extracted folder and the adb command should be in there as shown in the following screenshot:
$ ls
To check the version of the adb command-line tool you have just installed, run the following command:
$ ./adb version Android Debug Bridge version 1.0.41 Version 34.0.1-9680074 Installed as /home/tecmint/Downloads/platform-tools/adb
How to Use Android Debug Bridge (adb) in Linux
In the following examples, we will run the latest version of the adb command installed using the instructions in the previous section.
Once you have adb installed on your Linux system, connect your device to the computer via a USB cable and enable USB debugging in the device system settings, under Developer options.
Next, run the following commands to list the devices connect to the computer, make sure to check on the devices for any prompts to allow access.
$ ./adb devices
From the output of the previous command, the string RZ8NA0V3HEY is created by adb to uniquely identify the device by its port number. The next column shows the device meaning the device is connected to the adb server. Other possible values are offline (device not connected or is not responding) and no device (means no device is connected).
To show more information about the device (device description for example product:a71naxx model:SM_A715F device:a71 transport_id:1), add the -l
flag.
This is useful if many devices are attached to the computer:
$ ./adb devices -l
To install an Android app using adb, use the install sub-command as follows. If you are installing a test app, remember to add the -t
flag:
$ ./adb install ~/MusiX.apk OR $ ./adb install -t /path/to/testapp.apk
If you have multiple devices connected to the computer, use the -s
option to specify the device’s serial number:
$ ./adb -s RZ8NA0V3HEY install ~/MusiX.apk
In case your connection to a device is lost, you can reset your adb host and start over from the beginning:
$ adb kill-server
To view all available command-line options, issue the following command:
$./adb --help
That’s it for now! For more information, check out the online adb documentation, which contains more use cases and command-line examples.