In a bunch of questions on this site I see answers telling us to execute adb shell or adb logcat and so on.

Now, I'm not an entirely clueless user, so I downloaded and installed Termux and have a shell prompt when I can type in commands, but - where does this adb thing come from? Do I download it as an app? It doesn't seem to be installed by default (On a Redmi 3S, Android 6.0.1).

Also, it seems like it's some kind of permission elevator. Is it like su? If not, how is it different?


About adb

To put it shortly, adb (Android Debug Bridge) is a utility made to be installed on a computer, in order to let it gain a shell on a phone that's either connected via USB cable, or on the same Wi-Fi network.

On certain devices running Android Lollipop (5.1.1) and possibly lower versions of the OS, it was possible to trick a device into connecting to itself, since the adb client came bundled in the phone as well. This is not possible any more because, from Android Marshmallow (6.0) onwards, Google removed the adb binary from the phones to reduce the usable attack surface.

It is possible, though, to manually reintroduce the adb client on a phone, without needing to compile the binary yourself. Refer to the adb tag wiki for more info about this topic, as well as about installation on a computer and general troubleshooting.

Where to get it

Some time ago, in order to obtain adb and another utility, called fastboot, one had to download the full Android SDK from Google, if they wanted an official package. Nowadays, a small, official bundle has become available, as XDA says. It includes binaries for the most common operating systems.

How it works

The adb client, installed on your computer, makes a connection to a plugged or otherwise detectable phone, by means of an internal server. Then, the user will be able to send a variety of commands to the phone itself, which will be listened to by adbd, a daemon residing on the phone.

When using adb, you impersonate the user called shell (UID 2000). This user is special, in that they can grant app permissions and access more information than a simple user. This fact, though, does not mean that adb is the same as su, as the latter lets you impersonate any user.

More info about adb and its workings may be obtained by looking at the official documentation.

Issuing commands from a phone

The majority of commands that can be issued via adb tend to be utilities that come preinstalled in a phone.

In order to access them, you need to install a terminal emulator app on your phone (note that Termux is special, in that it specifies its own PATH, thereby ignoring system binaries). This will, for example, let you issue commands such as logcat directly on your mobile device. Remember to omit the adb prefix, though.

It is worth mentioning that, should you lack root permissions, the range of commands you'll be able to execute and the info you'll be able to access will be significantly less than if using adb, because the UID that invokes them will be the app itself, and apps have less permissions than UID 2000.

  • Well done! Unfortunately I cannot upvote twice :) // Yeah, our wikis are far too often "unknown quantities". Cannot point there often enough. But including a link in any answer mentioned in it is going a bit far IMHO :) Where it fits (like here: "for further details …"), a good idea. Feel free to go ahead with that – I go ahead for comment cleanup meanwhile :) – Izzy Nov 10 '17 at 15:16
  • @Izzy Good point. Let's wait and see if link spamming is actually needed. – Death Mask Salesman Nov 10 '17 at 15:27
  • Have my upvote, please. – iBug Nov 15 '17 at 13:26
  • @iBug I am honored. – Death Mask Salesman Nov 15 '17 at 13:37

Android Debugging Bridge (ADB).

It sends commands over USB or Wifi to an android device. It is typically installed on the computer connected to the device. The ADB client can also be run on device itself however the idea is to remotely debug the device.

It is part of the Android Software Development Kit

You can then use the SDK manager to download platform tools.

There is also a more direct link here in case you're just interested in the platform tools

ADB Documentation

  • Wait, if it's not installed on the device, why do people suggest I use it in shells on the device? e.g. in the examples I gave? – einpoklum Nov 10 '17 at 10:52
  • Thats a good point. Maybe its more correct to say adb command is the "client" connecting to a android device. The android device can also have the client on it because why not. But thats sorta like running ssh localhost – jdwolf Nov 10 '17 at 10:57
  • To be honest the documentation explains all this well: developer.android.com/studio/command-line/adb.html – jdwolf Nov 10 '17 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.