The difference between sudo
and su
is how they perform authentication:
su
prompts for the target user's password.
sudo
checks whether the source user is authorized to run the command (the authorization is specified in /etc/sudoers
). Depending on the configuration, it might prompt for the source user's password, both to mitigate the risk of an unattended console and to alert the user that privilege escalation is going on.
Once authorized, the effect is the same: run a command as root (or, if specified on the command line, as some other user).
There are further minor differences: they don't take the same options, and they don't set the environment for the command they run in exactly the same way. The meaning of “command” is slightly different: for su -c
, it's a string that's executed by the target user's shell, whereas for sudo
with no options, it's a program to run with arguments. But for common usage, they're the same.
sudo
,su
and dosu
andsudo
use different passwords.