The difference is that sudo
uses privileges attached to the account you're running as, while su
is more similar to logging in at a normal prompt as the user you're changing to.
Try su root
as a regular user that doesn't have permissions in the sudoers
file - you can use the root
credentials to change to that user, regardless of your current user's rights.
Conversely, sudo
and the permissions assigned in your /etc/sudoers
file allow your current user to work as root without needing to know any password but your own. For instance, add sudo
to the front of your su -u fred
command - fred's password is no longer needed, since the su
is then running with root privleges.