Why does sudo work on Linux but not Android

androidprivilegesrootsudo

I have not had the chance to read enough about Android, Linux, or UNIX to answer this myself. sudo works on a Linux machine but doesn't work on Android unless you root the mobile device (e.g. Samsung GT-N8013). Why does the mobile device require to be rooted, but not the typical Linux install?


The context of my question is related to
https://stackoverflow.com/questions/14019698/adb-shell-sudo-on-windows-7/14019726#14019726

(Also, is there any way for a program to ask to run as root on Android, the same way you have escalation of privileges to "run as administrator" on Windows? If you think this question should be on its own thread, I can create one)

Best Answer

sudo is a a normal application with the suid bit. This means in order to use sudo it has to be installed on the system. Not all Linux systems have sudo installed per default like for example Debian.

Most Android systems are targeted for end users who don't need to know the internals of Android (i.e. each Android applications runs under it's own user), so there is no need to provide an interactive way for an enduser to run a command as system administrator.

In general you can use su instead of sudo to run a command as a different user but you have to know the credentials for the target user for su (for sudo you have to know the credentials of the user running the command)

Related Question