What are the benefits of sudo over su?

So in what case root can cause damage whereas sudo can't?

Since you must usually invoke sudo each time you want to do something that requires privileges, the reasoning is that you will "think before you leap", i.e. not just stick sudo in front of something without thinking for a second what the command you're running is going to do.

With su on the other hand, once you're in, you're in. You have carte blanche (an open license) to do anything and everything, and the reasoning is you might forget for a moment that you have those privileges and if you're unlucky, execute something that will seriously affect/damage your system -- if you did not have su privileges, the command wouldn't have done anything serious.


IMO the major advantages of sudo over su are that sudo has superior logging of what commands were run and sudo gives finer control over what users can do.

su is all or none, but sudo can be configured to allow access to some, but not all commands.

See https://help.ubuntu.com/community/RootSudo for a more complete discussion, including advantages and disadvantages.


su -

When logged in as root, any task you start, action you trigger, or random event caused by visiting a certain website, etc. .. will run as super-user.

sudo

When you invoke sudo, as you run a command, only that command will run as super-user.

You will be asked for your password, before the command is executed. So user-interaction by you is also required.

Attempts to invoke sudo can also be logged.

Tags:

Sudo

Su

Root