Rooting Android Devices

Android is built on Linux. In Linux they are different users but the super user is called root. This usr can perform any operation on the Android device. The process is enabling the root on the device is called rooting. Once a device is rooted you will have full root access to the device.

Check for root access

To check for root access, first open a shell on the device and change to the root user by running the su command.

adb shell

and then then run the su command, switch user :

su

If the device is rooted your prompt will change into a # symbol, if not you will get an error that the command is not found.

By default the Android emulator is already rooted, it give you root access to the device.

Rooting an android device

Rooting an Android devices requires a few steps :

  • Unlocking the boot loader
  • Install recovery software like TWRP or CF
  • Install the Super Su app

Unlocking boot loader

By default most devices comes with their boot loaders locked. In order to root the device the boot loader needs to be unlocked first. The process to unlock the boot loader is dependant on the device manufacturer.

The Google Nexus phones are the easiest to unlock since Google seems to lax the rules on rooting the device. Some devices like Sony and Huawei requires a vendor provided code to unlock the boot loader.

Boot the device in fastboot mode

Depending on the device, they different key combinations used to enter the fast boot mode. Check with the device manufacturer.

  • Connect the device to the computer
  • On most devices hold the Volume Up + Power Button whilst the device is off
  • The device will boot to the fastboot mode prompt
  • Run fastboot devices to list devices connected in fastboot mode
  • Run fastboot oem unlock

If the process is successful the device will be unlocked.

Warning

Unlocking a boot loader on Google devices wipes all the data from the device. Backup the data before performing this operation. The device might go into a loop and continually keep restarting, check on http://www.stackoverflow.com for solutions.

Installing recovering software

The Android system comes with a recovery partition. This is used when making updates to the device without wiping the user data. The default recovery that comes with most devices can only perform limited functionality. In order to root a device, a custom recovery is required. Custom recovery options have options like creating restore points, applying unsigned updates, wiping data selectively, taking backups, copying data to the SD card and many more.

They are different recovery software packages but the popular ones are :

  • TWRP
  • CF

Installing TRWP(Team Win Recovery Project)

On Samsung devices you can use the Odin or Heimdall software to for installing th recovery software on your phone.

  • Download the TRWP recovery tarball
  • Download the IMG for your specific phone version from the TRWP website.
  • Download Odin
  • Put the device into download mode. On Samsung devices you press the Volume Up + Home + Power button simultaneously.
  • Connect the usb device when the phone reboot in download mode
  • Accept the warning with the Volume Up key to continue
  • If everything went well Odin’s ID:COM will turn blue to show that its successfully connected.
  • Choose AP and select the recovery IMG image from the previous step. AP is under the Files[Download].

Note

Make sure Auto Reboot and F. Reset Time are checked under the option group.

  • Click Start to begin the recovery. You should see PASS after a few seconds if everything goes well and the phone will restart.

Installing SuperSu

  • Download the from here
  • Copy the zip to device using adb with adb push <path to supersu zip> /sdcard
  • Reboot the phone into recovery mode by pressing the volume up, home, and power buttons simultaneously
  • Choose Install from the TWRP menu
  • Choose the Updated Super Su Zip and start flashing the device.
  • Reboot the device once the install is complete
  • The SuperSu will be added to the home screen
  • Test the installation by using adb, and run adb shell. Once on the prompt, type su. If everything worked you should now be presented with the root prompt. The root prompt have a # symbol.

Congratulations you have rooted your Android device.