Saturday, October 8, 2016

How exactly does "root" work? Do all applications run as root on my phone after rooting?


I've been reading about rooting the phone, but I have some concept doubts: when you buy an Android phone from a carrier, you don't have "root" access. When you start your phone, does that mean a "user" account (like I have on at Linux/Mac, '/home/myself') is used? Does '/home/myself' or similar exists in Android phones?


If I "root" a phone, will I start the phone as root when I turn it on? Will all applications now run as root? Or when they try to be run as root, I will need to permit them so?


If Android is essentially a Linux, to backup my device, shouldn't I just be able to connect to root it, do a full tar -cvzf / and then scp to somewhere? Why would I need to have Nandroid and these full-blown solutions?



Answer





When you start your phone, does that mean a "user" account (like I have on at Linux/Mac, '/home/myself') is used? Does '/home/myself' or similar exists in Android phones?



No. Android was designed for a single-user system, and a lot of the design decisions were made such that /home/myself no longer exists. In Android, Linux kernel's multiuser capabilities is used to enhance security instead, by running each application as its own user; therefore isolating each application's data from each other.



If I "root" a phone, will I start the phone as root when I turn it on? Will all applications now run as root? Or when they try to be run as root, I will need to permit them so?



No, No, Yes. In modern rooting methods (which is basically every rooting methods except for the earliest ones), there is an application called "Superuser" which is used to manage applications which are allowed to gain root access.



Since Android is a Linux, I'm interested in having access to a terminal and some unix utilities (ssh, rsync, etc). I don't mind having to use a bluetooth keyboard and vi (to edit /etc/hosts for example) if needed. Is this possible? Can I have a terminal with a lot of unix utilities (I know busybox is available)?




Yes, a shell exists (but it's not the bash shell). You may need to install Terminal Emulator to access it (some custom ROM installs it by default) or use it as a remote shell using ADB. Because it doesn't use bash, the terminal will be slightly different from what you're used to seeing in regular Linux distros (notably it doesn't have autocompletion) and most shell commands that you consider "standard" does not exist or only exists in extremely barebone form.


If you're using the terminal a lot, it is possible to install busybox and bash for a more familiar terminal experience; you can also install GNU userspace utilities, but you'll need a fairly high-end phone with heaps of disk space for it.


In short, what you want is possible; although a lot of the tools aren't installed by default on manufacturer ROMs. It takes a fair bit of work to install all those tools yourself, the easiest and fastest route is to install a custom ROM that provides those tools like CyanogenMod.



If Android is essentially a Linux



Android uses Linux kernel, but it is not a GNU/Linux and does not use the typical GNU userspace programs. Instead it uses the toolbox userspace, which is a very minimalist userspace (even smaller than busybox, toolbox doesn't even have a cp, you have to use cat instead to copy files). Some custom Android ROMs installs busybox by default.



to backup my device, shouldn't I just be able to connect to root it, do a full tar -cvzf / and them a scp to somewhere? Why would I need to have Nandroid and these full blowns solutions?




which is essentially what Nandroid does (strictly speaking, Nandroid backup is more like backup with dd rather than tar though), except with a much more convenient GUI. Most people, even power users, don't like typing complex commands on the small keyboard or having to connect an external keyboard every time they want to backup (and 99% of the world has a Terminal-phobia). It's much easier to just start an app and click a button and have all those done for you.


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...