How to Use ADB Android Debug Bridge to Manage Your Android Mobile Phone

Mobile phones have evolved a lot over recent years, and we have seen several mobile-vs-desktop management solutions like Samsung DeX for Samsung Mobile phones, and only available for Windows 7 and 10 as well as Mac. As a non-Samsung or Linux user, one may feel left out. Not so! In fact, a whole lot more power can be provided by the ADB toolset from the Android developer team! This article will introduce you the same, and we have two followup articles which describe How to Mirror Your Android Mobile Screen to Linux and How to Remove Bloatware From Your Samsung Android Mobile Phone.

In this tutorial you will learn:

  • How to install ADB on your Linux workstation
  • How to connect your phone using a physical USB cable
  • How to connect to your phone using ADB
  • How to change the setup to enable wireless access to your phone via ADB

How to Use ADB Android Debug Bridge to Manage Your Android Mobile Phone

How to Use ADB Android Debug Bridge to Manage Your Android Mobile Phone

Software requirements and conventions used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Linux Distribution-independent
Software Bash command line, Linux based system
Other Any utility which is not included in the Bash shell by default can be installed using sudo apt-get install utility-name (or yum install for RedHat based systems)
Conventions # – requires linux-commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires linux-commands to be executed as a regular non-privileged user

Installing ADB on your Linux workstation

Installing Android Debug Bridge on your workstation is relatively easy. As Android Debug Bridge is part of the Android SDK (Software Development Kit), there is also less risk then there would be by using any other non-Android-provided utility or software package.

Firstly, you want to make sure you have a terminal window open. Execute the following command for Ubuntu or Mint:

$ sudo apt install adb

If this command fails, use android-tools-adb instead of adb. If you are using Fedora, use sudo yum install adb instead. You could also use/try dnf instead of yum.

Activating the Android Debug Bridge

Once you have ADB successfully installed, you need to start the ADB server on your Linux workstation. To do so, simply type adb start-server at the command line. You will want to see the following output:

$ adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully

Almost ready to connect!

Enabling Debug Mode on Your Mobile

Grab your Android based phone, and following the following menu steps:

Settings > About Phone > Software information > Scroll down to ‘Build number’ and tap that box 7 times. If debug mode was already activated previously, you will receive a message that says ‘No need, developer mode has already been enabled’.

If you have not used debug mode previously, after 3 presses of the same (during which nothing seems to be happening), you will finally start to see a countdown timer indicating that you are 4.. 3.. 2.. 1.. presses away from being a developer. After this it will ask for your password and provided that is entered correctly, developer mode will now be enabled on your phone.

If you ever want to disable developer mode, it is simply to do:

Settings > Search > Type ‘developer options’ > Select the ‘Developer options’ under ‘Developer options’ (and not the one under ‘Screen reader’) > Slide the top blue slider from On (right) to Off (left).

Enabling USB Debugging on Your Mobile

Follow the following steps to enable USB debugging mode on your mobile:

Settings > Search > Type ‘developer options’ > Select the ‘Developer options’ under ‘Developer options’ (and not the one under ‘Screen reader’) > Scroll down to ‘USB debugging’ directly under the ‘Debugging header’ and slide the switch from Off (left) to On (right) > Press ‘OK’ to confirm you want to enable USB debugging.

Connecting your Mobile via a USB Cable

You will want to unlock your phone before you connect it your computer. Don’t worry if you forget, the dialog boxes which will come up on your phone, and which you will need to acknowledge, will still be there after your connect your phone and login, but it easy and more self-explanatory how things work if you unlock your mobile at this point.

If your Android mobile came with a USB cable you can likely use that one to connect the phone to your computer. If not, find a cable which is compatible with both your phone and computer. For example, to connect a USB-C phone to a USB 3 port on your Linux workstation, you likely want to use a USB-C to USB(3) cable and use a blue port on your workstation. Look at your USB port internal connector color to see what level / speed port it is: blue ports are USB 3, black or white ports are USB 2.

Importantly, you likely will want to avoid using a USB-C to USB-C lead at this point in time (2020), even if both your phone and your workstation are USB-C enabled. While you may be able to get it working, USB-C is a fairly new technology when it comes to “Connecting your Android phone via ADB to your Linux workstation”, if you catch my drift. I have seen some interesting issues with new hardware being unable to connect via USB-C to USB-C setups, very likely because of as-yet limited support in the Linux Kernel etc. I thus recommend using a fairly common USB-C to USB(3, i.e. blue) cable.

Once you got the right cable, remember to unlock your phone and then simply plug it into your phone and an empty USB slot on your machine, preferably an internally blue one (USB 3), to enable maximum throughput.

Allowing your PC to Manage Your Phone via Debugging Mode

It is somewhat important that you only connect your mobile phone to a computer you trust. Never connect your phone for ADB level debugging to for example a PC in an Internet cafe. The method described here gives your PC a fair bit of power over your Android phone, and this comes with the responsibility to be more responsible. This is not just installing or uninstalling an App on your phone via the App store 🙂

Once you connect your phone to your computer you will be presented with two dialog boxes, as follows:

Allow USB debugging?

Allow USB debugging?

This dialog shows your computer’s RSA key fingerprint ID. Tick the box ‘Always allow from this computer’ if you would like to have an easier setup next time, and if you trust the computer this is being connected to (and do not proceed at all if you do not trust this computer), and then click ‘Allow’ if you are ready to proceed.

You will be presented with one more dialog box, which looks similar to the one you see when connecting your phone to your computer without USB debugging enabled:

Allow access to phone data?

Allow access to phone data?

Select ‘Allow’ when you’re ready to proceed.

Coffee (or RedBull): Break Time!

Phewy. Still with us? Great! Time for a little break.

The first time one does this it may all feel a bit scary, and perhaps a little crazy. Why? It’s the underlying (somewhat true) realization that your new $1000 (or more) USD phone may soon be messed up if you make mistakes. True enough, there are some things that you could break, but so far we haven’t touched on any of these yet 🙂

The procedure which is most likely to make any damage, if any, is the one described in our How to Remove Bloatware From Your Samsung Android Mobile Phone article. That said, it may help you to know that I executed the exact procedure described there on two recent Samsung mobile phones without any issues, except some Facebook connectivity problems. To avoid this, and if one uses Facebook at all, one could leave out the Facebook specific steps from the procedure provided there. In any case, no guarantees are given or provided, and any information is provided as-is. That said, I personally had zero issues with this.

Another cool thing is that the Android ADB bridge is a fair bit less risky (but not without risk) then for example rooting your phone. I personally find ADB the ideal middle; no messing around with your phone, nor accept all the bloatware installed which makes your phone slower and uses a lot of battery.

You will be happily surprised what happens with your battery usage once most bloatware is gone (and you optimize some settings like battery use, background data usage, screen brightness and resolution – lower is better for your battery for both these settings). Just uninstalling bloatware seems to have a added 1-2 extra days of battery life to my phone (per charge).

Another great feature of the ADB bridge is that you will be able to directly use your mobile screen via a remote mobile desktop utility built in directly to ADB.

Connecting your Mobile via ADB (USB Mode)

Next, we need to use adb to fetch a list of devices connected to this workstation. At your command line, execute adb devices:

$ adb devices
List of devices attached
UI84762QNI3 device

Great, so we see that device ‘UI84762QNI3’ is connected to the workstation.

How about if you could, at least partially, see all directories from root down on your mobile? Easy:

$ adb shell
z3s:/ $ pwd

We first connected via adb shell to the single device connected via USB (this may fail if more then one device is present). This effectively connects us to the phone and provides us a command prompt, on the mobile. You can confirm you’re in root by executing pwd and the output should be /. If it is not, simply execute cd /.

Next, simply type ls and you will see all directories in the root of your mobile device! Let’s next check out the processor information in /proc/cpuinfo:

z3s:/ $ cat /proc/cpuinfo | grep -E 'processor|BogoMIPS'                                 
processor   : 0
BogoMIPS    : 22.00
processor   : 1
BogoMIPS    : 22.00
processor   : 2
BogoMIPS    : 22.00
processor   : 3
BogoMIPS    : 22.00

To exit the console, simply type exit at the ADB specific command prompt.

z3s:/ $ exit

Most commands can be stacked behind adb shell on the command line. For example, one could do adb shell pwd; ls / instead of the above, and this has the added advantage that any output (for example directory listings) will be color-coded correctly if your terminal supports it, which is not the case if we use an interactive shell via adb shell.

Uninstalling packages is the topic of our next article, but for now we can list what applications are installed by using adb shell pm list packages.

Connecting to Your Phone Wirelessly

Now that we have done our initial connection via USB, we can instruct our phone to allow wireless connections, then disconnect the USB cable, and connect wirelessly. Sounds complicated, but it is easy to achieve:

$ adb tcpip 2233
restarting in TCP mode port: 2233

As the first step, we instructed ADB to enable a TCP/IP (network) connection on port 2233. Select a new port number for your own setup to increase security. Select something, for example from the range 1000-19999.

Next, you will want to disconnect the USB cable from your mobile, and again on your mobile go to:

Settings > About phone > Status > Note the IP address under ‘IP address’. Use the IPv4 IP address and not the IPv6 address which is generally listed first. The IPv4 address is the one with only numbers, no letters.

Next, jump back to the terminal on your workstation and connect via the IP address you just noted down as well as the port number we defined earlier. Thus, in other words, the connect command on your computer will look different then the one below for both the IP address as well as the port used:

$ adb connect
connected to

If you see output similar to this; well done: your phone is now connected across your Wi-Fi network via ADB to your workstation. You can now check the list of devices:

$ adb devices
List of devices attached device

From here you can work exactly as we did before: adb shell will provide a shell to your phone etc.

If you would like to disconnect ADB at any point, simply execute adb disconnect.


In this article, we explored installing ADB on your Linux workstation, and connect your phone via USB using a physical USB cable as well as via a wireless connection. The power is now in your hands, use it well and responsibly! Continue reading our How to Mirror Your Android Mobile Screen to Linux and How to Remove Bloatware From Your Samsung Android Mobile Phone articles to learn more.

Comments and Discussions
Linux Forum