why does sudo work on Linux but not Android?
Solution 1
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)
Solution 2
sudo
is not universal. Just because it exists on the particular Linux distro you use, doesn't mean it's available on all OSes that also use the Linux kernel.
Solution 3
The phone has to be rooted to have the root
user install sudo
(or any other app). Otherwise it would be installed as the "standard" user and not have root access.
As for the second question, once sudo
is installed on the rooted phone, in my experience, the apps that need it simply request it and you get a popup prompt.
Solution 4
You touch on a critical point in your question: a typical Linux install IS rooting: you boot from a Live CD and overwrite the bootsector of the harddrive to load your own code.
It's just that rooting a PC is less arduous than on a semi embedded device like a phone so that people tend to forget that installing a second OS with dual-boot is essentially rooting (the only thing that will fight you on this is the BIOS with secure boot but that can be easily reset).
And the OS on the Android device just doesn't come with the sudo
command (or similar) installed.
Related videos on Youtube
HimanshuArora9419
Updated on September 18, 2022Comments
-
HimanshuArora9419 over 1 year
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)-
Admin over 11 yearsIt should be in
sudoers
list to getsudo
. Its not in Android an Ubuntu
-