Reputation: 19482
Basic question on ADB.
adb root
restarts adb as root. But what i want is to restart it back to user after some time.
I tried the following :
adb kill-server
adb start-server
doesnt work..
ps -A
-> noted the process number of adb and killed it.. even this did not work. Finally i am restarting my device. Is there any way i can come back from root adb to general adb?
Thank you.
Upvotes: 58
Views: 128827
Reputation: 2525
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
Upvotes: 43
Reputation: 1
if you cannot access data folder on Android Device Monitor
cmd
C:\Users\bscis\AppData\Local\Android\sdk\platform-tools
(Where you located sdk folder)
C:\Users\bscis\AppData\Local\Android\sdk\platform-tools>adb shell
generic_x86:/ $
C:\Users\bscis\AppData\Local\Android\sdk\platform-tools>adb kill-server
C:\Users\bscis\AppData\Local\Android\sdk\platform-tools>adb start-server
* daemon not running. starting it now at tcp:5037 *
* daemon started successfully *
C:\Users\bscis\AppData\Local\Android\sdk\platform-tools>adb root
C:\Users\bscis\AppData\Local\Android\sdk\platform-tools>
working fine.....
Upvotes: -2
Reputation: 123
i've been with this issue using elementary OS loki. For like one day and i solved it restarting the adb using this command:
./adb kill-server
and
./adb start-server
You need to be in the Sdk folder >Platform Tools
Now, restart your phone this will restart all the process in your phone.
And that's how i fixed it.
Upvotes: -1
Reputation: 131
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 &
.
Upvotes: 12
Reputation: 19482
For quick steps just check summary. If interested to know details, go on to read below.
adb is a daemon. Doing ps adb
we can see its process.
shell@grouper:/ $ ps adb
USER PID PPID VSIZE RSS WCHAN PC NAME
shell 133 1 4636 212 ffffffff 00000000 S /sbin/adbd
I just checked what additional property variables it is using when adb is running as root and user.
adb user mode :
shell@grouper:/ $ getprop | grep adb
[init.svc.adbd]: [running]
[persist.sys.usb.config]: [mtp,adb]
[ro.adb.secure]: [1]
[sys.usb.config]: [mtp,adb]
[sys.usb.state]: [mtp,adb]
adb root mode :
shell@grouper:/ # getprop | grep adb
[init.svc.adbd]: [running]
[persist.sys.usb.config]: [mtp,adb]
[ro.adb.secure]: [1]
[service.adb.root]: [1]
[sys.usb.config]: [mtp,adb]
[sys.usb.state]: [mtp,adb]
We can see that service.adb.root
is a new prop variable that came up when we did adb root.
So, to change back adb to user from root, I went ahead and made this 0
setprop service.adb.root 0
But this did not change anything.
Then I went ahead and killed the process (with an intention to restart the process). The pid
of adbd
process in my device is 133
kill -9 133
I exited from shell automatically after I had killed the process.
I did adb shell
again it was in user mode.
SUMMARY :
So, we have 3 very simple steps.
(pid of adbd)
After these steps just re-enter the shell with adb shell
and you are back on your device as a user.
Upvotes: 1
Reputation: 1396
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
Android SDK
and you have set paths to binary files. type which adb
on your shell. It must give you somewhat result.
$ which adb
/Applications/Android Studio.app/sdk/platform-tools/adb
On your Mobile
ON
Apps and ADB
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
Upvotes: 2
Reputation: 528
This is a very common issue.
One solution is to kill adb server and restart it through command prompt. Sometimes this may not help out.
Just go to Window Task Manager to kill adb process and restart Eclipse.
Will work perfect :)
Upvotes: -1
Reputation: 31706
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)
Upvotes: 32