[Android Software/Hacking General [Developers Only]] meltwater:
Topic Three: Low Level Basics

Part Two: The Root Of It All

I looked and looked for this information but I couldn't find the clear answers I wanted regarding rooting, so here is the info I was after.

What is ROOT, do I need it?

Rooting your device is not essential, for most the things you do with a tablet you will not need root access. Rooting is the process by which you enable “Root” access to the system’s low level files and hardware, this is achieved by enabling “super user” [Linux term for the highest level access which has higher level permissions to files than a normal user (like an Administrator)] access.

In most cases, apps will access hardware and files through the Android API, but in some cases they may need better control of the hardware than the API allows or access to files which are normally locked.

For this reason these applications require “root” access, typically apps which take screenshots (I assume to allow access to the screen data) and backup programs (I expect to allow access to all your files) are such programs.

Am I Rooted?

One thing I had trouble working out was working out if the device was rooted already or not. The quickest way to find out is to try to use an app which requires root access, if you device isn’t rooted it will tell you.

A good way is to download “Terminal Emulator” from the market (or direct from the author) . Then type: su which stands for Super User! (if your device is correctly rooted the “$” will change to “#” (ideally it will also prompt you for permission to enter superuser mode first - see SuperUser.apk below)).

Other signs you are rooted is to look for the “su” file in /system/bin/ but this will not confirm if the file is set to be executable correctly or in some cases different names are used to make it harder for unwanted apps to locate it.

Can I break/brick my device by ROOTING?

Actually ROOTING the device shouldn’t really cause any problems (since all you are really doing is installing a file which allows you to grant “Superuser” access). However, since ROOTING (by definition) allows entering into “Superuser” mode, this mode does allow you make much more serious changes to the system than you would in a “Normal User” mode (which is the whole point!), so clearly there are some risks involved while in this mode (and you may want to consider how this fits with your warranty). If your device isn’t open, then I suspect the main risk is getting your device into an unlocked state so that you can perform the root process first (since my tablet was not locked in anyway, I don’t know about this aspect).

Once ROOTING is complete, you don’t remain as a “Superuser” but any application is able to use it if they require. For this reason, the Superuser.apk application is typically installed, which detects when a request for “superuser” permissions are made and allows you to accept or reject the request.

The ROOTING process itself is reversible, which you may wish to do if you need to return your device for repairs etc.

How to root?

There are many guides and methods, but I shall take one specific to my tablet (posted by OffWorld on androidtablets.net) and explain each step in detail, since none I found explain what it is you are doing.

First you need to get the latest su and superuser.apk files from here.

Now, connecting the device to your pc, open a command prompt and type:

adb devices

Adb will respond hopefully with your list of devices:

List of devices attached

0123456789ABCDEF device

This confirms your device is attached and adb is able to communicate correctly.

Command 1:

adb shell mount -o remount,rw /dev/block/mtdblock3 /system

This runs adb (the terminal program to your device) and mounts the specified folders with read/write access.

Command 2:

adb push su /system/bin/

This sends the “su” program to the location on the device (note this assumes have the “su” in the same directory as you are running adb from). You can confirm this by navigating to the location on your tablet and see that the file has been transferred.

Command 3:

adb shell chmod 4755 /system/bin/su

This changes the permissions of the “su” file you’ve just transferred [details about chmod].

By using the command: adb shell ls -l /system/bin/su you can see the permissions.

We’ve changed the permissions from -rw-rw-rw- to -rwsr-xr-x, this allows the file to be executed.

Command 4:

adb push Superuser.apk /system/app/

This installs the Superuser.apk package on the device. This is important since this app allows you to control superuser access, rather than just allowing any program to obtain “superuser” rights.

Command 5:

adb shell reboot

Restarts the device.

Following this process, you will have the SuperUser application installed and applications will request Superuser access if they require it.

Note:

You may find for screen capture programs you need to allow permissions automatically or you may only end up with screenshots of the permission screen! Yes that's how I got the above one...