- When you run an executable, sometimes the OS will deny your
permission to. For example runningmake install
with the prefix
being a system path will needsudo
, while with the prefix being a
non-system path will not be asked forsudo
. How does the OS decide
that running an executable would require more privilege than a user
has, even before the program does something? - Sometimes, running a program will not be denied permission, but the
program will be able to do more things if it is run withsudo
. For
example, when runningdu
on some system directory, only with
sudo
it will be able to access some directory. Why does the OS not
deny permission of running such a program, or friendly notify more privilege is preferred, before the program can run? - Is it true that whenever
sudo
works,su
will also work, and
wheneversu
works,sudo
will also work? or withsu
, a user can do
more than withsudo
? How does the OS decide whensudo
works, and
whensu
is needed?
How does the OS know that a command needs sudo
permissionssudo
Best Answer
sudo
you are running it under some other user's name. If that user is "able to do more things" than your user and thesudo
configuration allows you to do these things on the other user's behalf then yes,sudo
will allow you to do more things. This is not necessary, though. If you just tacksudo
on at the beginning of the command line, you're actuallysudo
ing asroot
, so typically you're able to do more things than a mere mortal.sudo
you need to supply your own user password and then you're allowed to do some things on the target user's behalf. To usesu
, you need the target user's password and if you have it, you become that target user as far as the system is concerned and can do anything that user can do.See also