How to restart adb from root to user mode?
I would like to add a little more explanation to @user837048's answer. on my OSX Yosemite and Galaxy S3 which is rooted and using firmware CyanogenMod 11
and KitKat
I have done the below proceedings to Enable
and Disable
root prompt.
Please make ensure below
On your system
- Make sure you have installed
Android SDK
and you have set paths to binary files. typewhich adb
on your shell. It must give you somewhat result.$ which adb /Applications/Android Studio.app/sdk/platform-tools/adb
- Make sure you have installed
On your Mobile
- Settings > Developer Options> Android Debugging =
ON
- Settings > Developer Options> Root Access =
Apps and ADB
- Settings > Developer Options> Android Debugging =
If you don't see Developer Options
in your settings, Goto Settings > About Phone. Scroll down to Build number
and tap there 7 times. I know its crazy. But believe me it works :D
Connect your phone via USB Cable.
type on your computer's
terminal
$ adb shell
you will see a prompt similiar, If any prompt has been shown on your mobile, to trust the connection, tap 'Always Trust' and 'OK'
shell@m0:/ $
now type
shell@m0:/ $ id
uid=2000(shell) gid=2000(shell) groups=1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats) context=u:r:shell:s0
See you are not root
Now exit from shell, which will fall back to computer's prompt
shell@m0:/ $ exit
Now activate root
$adb shell
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
root@m0:/ #
Wow.. you are root
root@m0:/ # id
uid=0(root) gid=0(root) context=u:r:shell:s0
I tried many solutions to go back to normal non root prompt
. But didn't worked except @user837048's solution.
root@m0:/ # stop adbd && setprop service.adb.root 0 && start adbd &
[1] 32137
root@m0:/ #
$
This might exit you from Adb prompt
to normal prompt. Now connect again.
$ adb shell
shell@m0:/ $
Well.. You are Non root
adb kill-server
and adb start-server
only control the adb
daemon on the PC side. You need to restart adbd
daemon on the device itself after reverting the service.adb.root
property change done by adb root
:
~$ adb shell id
uid=2000(shell) gid=2000(shell)
~$ adb root
restarting adbd as root
~$ adb shell id
uid=0(root) gid=0(root)
~$ adb shell 'setprop service.adb.root 0; setprop ctl.restart adbd'
~$ adb shell id
uid=2000(shell) gid=2000(shell)
Try this to make sure you get your shell back:
enter adb shell (root). Then type below comamnd.
stop adbd && setprop service.adb.root 0 && start adbd &
This command will stop adbd
, then setprop service.adb.root 0
if adbd
has been successfully stop
ped, and finally restart adbd
should the .root
property have successfully been set to 0. And all this will be done in the background thanks to the last &
.
If you used adb root
, you would have got the following message:
C:\>adb root
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
restarting adbd as root
To get out of the root mode, you can use:
C:\>adb unroot
restarting adbd as non root