How can I get root permissions in a terminal?
5 Answers
Type su
and your terminal prompt should change from $
to #
. This is assuming that your device is already rooted.
-
3
-
-
-
-
1@HXCaine: If you don't have permission to run
su
, you probably don't have permission tochmod
it. Apr 6, 2013 at 21:41
See the following questions:
-
1
Production phones don't ship with root access, developer phones do. If you have a production phone (likely: you'd know if you bought a dev phone), you have to "root" them first. As @Joe_Casadonte points out, there are some great instructions here and elsewhere (Notably the CyanogenMod Wiki and Android Rom's google group) to get you started rooting your phone. (And if you get stuck ... come back here with your questions!).
Once you've rooted your phone, you can gain root privileges in the adb shell or the terminal emulator with the su
command.
Note: it sounds from some of your responses like you haven't yet rooted your phone. So you'll need to start there.
Assuming that:
- Your Android device is rooted;
- The
su
binary is located at/system/xbin/su
; - The shell binary is located at
/system/bin/sh
; and - Your Android device has Terminal Emulator installed.
If all the 4 conditions above are satisfied, then:
If you want to enter the shell and become root (superuser uid 0) so you can execute commands without uid restrictions, start the Terminal Emulator app and just execute this command:
su -
In order to disconnect from the uid 0 (exit superuser status), press Volume - and D, or type
exit
and hit EnterAlternatively, if you want to always start Terminal Emulator as root, then start Terminal Emulator, go to Preferences, scroll down to the SHELL section, tap the Command line option and modify the command so it becomes this:
/system/xbin/su -c "/system/bin/sh -"
After you change the command, exit Terminal Emulator (close the application) and start it again. Notice how Terminal Emulator's shell interface now shows you
root@something
by default.
For my 8.1.0 go edition phone. It is /sbin/su -c "/system/bin/sh -"
. I struggle too much to figure out where is su
binary file(in my case su
binary not exist in the /system/xbin/
path). I found a path /sbin/
is exist in ROOT directory and su
binary is exist in that path. And of course i rooted my phone by magisk manager. Hope this answer will help someone.