Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adb shell su works but adb root does not

I rooted my unlocked Galaxy S3 (SGH-T999)

Now, I'm trying to run adb root from Windows Command Prompt, however, I'm getting adbd cannot run as root in production builds error. So, the very first thing I checked was whether my phone was really rooted?

So I tried the following:

Open Command prompt

$adb devices // lists my device
$adb shell //goes to shell
$su // opens a 'SuperSu' prompt on my phone and I 'Grant' permission
# // Before following the rooting instructions, I was getting 'no su command found' in the previous step. So, I believe my phone is ROOTED. **Correct me if I'm wrong.**

However, when I do adb root, I get adbd cannot run as root in production builds error. So, I thought, I might have to do some additional stuff beyond what I did above. I tried all the solutions in the following SO questions:

  • Launch a script as root through ADB
  • adb remount permission denied, but able to access super user in shell -- android
  • Unable to run 'adb root' on a rooted Android phone

None of the above worked for me. All they do is give the ROOT access INSIDE of SHELL. I want adb root to work so that I can execute various adb commands WITHOUT going into shell.

like image 877
rumit patel Avatar asked Aug 24 '14 23:08

rumit patel


People also ask

How do I enable root on ADB?

root access is disabled by system setting - enable in settings -> development options Once you activate the root option (ADB only or Apps and ADB) adb will restart and you will be able to use root from the cmd line.

Does ADB work without root?

You don't need to be rooted to use ADB, all android phones can use ADB without being rooted. You must be rooted to push applications to /system/apps/ to make them system applications.

Why is ADB command not working?

If the ADB command is not found, most likely you need to install the Android SDK Platform-Tools package to make it available in the command prompt. Also, the phone should be in USB debugging mode.

Is ADB and root same?

Quantum, root is a user in Android having supreme privileges to do anything. ADB doesn't grant you rights enough to compare with root or system user. In short, there is no replacement for root access.


4 Answers

By design adb root command works in development builds only (i.e. eng and userdebug which have ro.debuggable=1 by default). So to enable the adb root command on your otherwise rooted device just add the ro.debuggable=1 line to one of the following files:

/system/build.prop
/system/default.prop
/data/local.prop

If you want adb shell to start as root by default - then add ro.secure=0 as well.

Alternatively you could use modified adbd binary (which does not check for ro.debuggable)

From https://android.googlesource.com/platform/system/core/+/master/adb/daemon/main.cpp

#if defined(ALLOW_ADBD_ROOT)
// The properties that affect `adb root` and `adb unroot` are ro.secure and
// ro.debuggable. In this context the names don't make the expected behavior
// particularly obvious.
//
// ro.debuggable:
//   Allowed to become root, but not necessarily the default. Set to 1 on
//   eng and userdebug builds.
//
// ro.secure:
//   Drop privileges by default. Set to 1 on userdebug and user builds.
like image 163
Alex P. Avatar answered Oct 08 '22 23:10

Alex P.


In some developer-friendly ROMs you could just enable Root Access in Settings > Developer option > Root access. After that adb root becomes available. Unfortunately it does not work for most stock ROMs on the market.

like image 23
NgaNguyenDuy Avatar answered Oct 08 '22 21:10

NgaNguyenDuy


I ran into this issue when trying to root the emulator, I found out it was because I was running the Nexus 5x emulator which had Google Play on it. Created a different emulator that didn't have google play and adb root will root the device for you. Hope this helps someone.

like image 30
Andrew Steinmetz Avatar answered Oct 08 '22 23:10

Andrew Steinmetz


I use for enter su mode in abd shell

adb shell "su"

like image 10
Samuel Ivan Avatar answered Oct 08 '22 23:10

Samuel Ivan