17

How can I get root permissions in a terminal?

Izzy
  • 91,166
  • 73
  • 343
  • 943
mahdi
  • 641
  • 3
  • 6
  • 8

5 Answers5

17

Type su and your terminal prompt should change from $ to #. This is assuming that your device is already rooted.

Lie Ryan
  • 19,073
  • 6
  • 65
  • 83
3

See the following questions:

Joe Casadonte
  • 1,216
  • 2
  • 13
  • 16
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.

Amanda
  • 3,423
  • 4
  • 39
  • 49
0

Assuming that:

  1. Your Android device is rooted;
  2. The su binary is located at /system/xbin/su;
  3. The shell binary is located at /system/bin/sh; and
  4. 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 Enter

  • Alternatively, 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.

0

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.