I seen a lot of apps in the market that give superuser functionality to applications. However there is a pre-requisite of rooting your phone. I am curious how a rooted phone has those permissions already?

I've downloaded the source code and have managed to locate the su.c file that might invoke an application to change. But im still not sure. Can anyone give an insight on this?

Which actual files delegate permissions? Are all system apps given root permissions at startup?

  • setuid doesn't work on Android since version 4.3. So a privileged daemon is run on boot: How Magisk works? Dec 2, 2020 at 3:23

5 Answers 5


Once upon a time, there is a walled city with a large, closed gate bound by magical lock that can only be opened with a magical sword. According to the cityfolk's traditions, anyone who brings the magic sword and unlocked the magical gate is destined to be the lord of the city.

One day, a young hero comes to the city, bringing with him the magical sword he took from the root of the Yggdrasil tree. He tapped the sword lightly on the door, and immediately the magical gate unlocked itself and peered open. The cityfolks cheered, and as per their tradition, they anointed the young hero as the city's lord.

As a city lord, there are many tasks he had to do, one of which is to ensure the security of his people, especially now that the gate is open and bandits and thieves may attempt to enter the city and rob the cityfolks' of their belongings.

To ensure the peaceful days of the cityfolks, the wise lord hired a trusted SU manager to guard the gate; dutifully, the SU manager enters the city, and he closed the gate behind him, and he put a lock that only he can open, then he creates a big door knob for strangers to knock the gate, a small hole on the door where he can peek outside and look at the strangers, then asks the city's lord whether or not to allow strangers in.

In eternity, the wise lord ruled the city for a long time and the cityfolks lives happily ever after.

  • 7
    This is great (no downvote), but a little too obtuse (no upvote). Mar 14, 2011 at 15:41
  • 2
    I lol'ed at this
    – Bryan Denny
    Mar 14, 2011 at 15:44
  • 1
    a good story with a happy ending.
    – Jayrox
    Mar 14, 2011 at 17:15
  • @MatthewRead I'm pretty sure that is literally how it works; Android is actually made of little people. ;)
    – CatShoes
    Nov 19, 2012 at 20:46

Which actual files delegate permissions?

There is typically a "superuser" application that is included in rooting processes. This application is the gatekeeper/controller of which applications get root access. Any time an application asks for root access, this application will pop up and ask you to either approve or deny the request.

Are all system apps given root permissions at startup?

As far as I know, everything must go through the "superuser" app.

  • Unless they exploit some other exploit to get root. This, hopefully, is not a large threat to most users.
    – CatShoes
    Nov 19, 2012 at 20:47

I've been hunting for an answer for this myself, and information has been really elusive. But between other answers and questions here, and reading the Superuser blog, I think I've been able to piece together how it works.

In a standard *Nix system, su checks if the user is authorized to become root (on some systems, everyone is; on others, they have to be a member of group wheel or something), prompts for the root password, and then grants root access.

On a rooted Android, what seems to be happening is that Superuser comes with a custom version of su that figures out what app invoked it, then checks the Superuser access database for whether or not that app is permitted to become root. If it is, then it makes the jump to root. If not, it spawns the authorization UI.


A developer has to call su within the application. once it calls that, and the user has granted permission to use su, then they run commands in the shell that has root permissions.

In a way, system apps have "special" permissions but not root like an app would get by calling su. They have the permissions that android grants system applications.


Unix based system have a special permission type called setuid which allows a file to be run by a non root user as if he is the root user.

In our particular case, su has the setuid permission and so it is being run as the root user.

Once invoked the su binary checks (with the SuperUser app) to see if it should grant the request for root to the requesting app, if the request is approved then it opens a shell as root, (which su can do since it itself runs as root because of the setuid permission that it has).


You must log in to answer this question.