If an Android user debug build comes with adb root access by default, does it contain the su binary to achieve this?
If not, is it any different from rooting your phone?
No, adb does not require a su
binary to get root permissions.
On a regular build, it is just the other way around: adbd
is started by the Android system itself with root permissions. Up to a certain point, it uses these root permissions (open port and so on), and then adbd drops the root permissions.
On an Android user debug build, it comes with adb root access. adbd
does not drop the root permissions, hence every command executed via adb is also executed with root permissions.
adbd
and su
are totally independent from each other. Each of them does not use the other on it's own. On a rooted device (where adbd
does not run in root mode) however you can inside the shell provided via adb (adb shell
) execute commands with root permissions via su
but that is a different topic because in this case you as the user use su
, the adb shell is just the "stage" you are working on.
I just built a userdebug
version of AOSP 10.0 for my Pixel 4 XL; it does contain an su
binary in /system/xbin/su
.
It differs from what many mean by "rooting" in that it doesn't let you actually run su
from on the phone itself (say, within Termux). It can only be executed by root or a member of the shell
group, which is what is used while running an adb shell session. However, it still is a way to run things as root; it merely requires an adb connection to do so.
If your USB cable doesn't carry data or your USB port is broken/faulty, you wouldn't be able to run things as root anymore (unless you had already set up adb
on the device to run over TCP).
I later put Magisk on my otherwise-AOSP ROM and now have two su
binaries; the Magisk one is installed in /sbin/su
. Magisk's /sbin/su
will let me run things as root without an adb connection active.
adbd
doesn't usesu
binary but latter is shipped withdebug
builds (if not explicitly removed by ROM developer). However thissu
is entitely different than the one we get when we root the device. Details here: What special privileges “/system/xbin/su” does have w.r.t. root access?. Also related: Why “adb root” does nothing?