Which approach is better?
For desktop usage, it seems that sudo is better since:
- I can have a more consistent history as a normal user
- Don't need to remember two passwords, which is especially true when I don't do administrative stuff regularly.
- No need to create an additional root account on installation.
But about in server management?
In server usually you already have a root account created and you are likely to do administrative stuff often. So the advantages of sudo seem no longer hold.
What's more, it's easy to configure su on command line in most distributions, just add the user to the wheel group. (You can even pass
-G wheel when
useradding.) Thus configuring su can be easily automated into shell scripts.
But for sudo? You need to first add the user, than run
visudo interactively. This is bad since you cannot automated it into shell scripts.
(Well, you can. For example,
echo '%wheel ALL=(ALL) ALL' >> /tmp/sudoers.tmp cp /etc/sudoers /etc/sudoers.old visudo -c -f /tmp/sudoers.tmp && mv /tmp/sudoers.tmp /etc/sudoers
But at least it is not that easy.)
So what's your opinions? For a server environment, which will you prefer, sudo or su root?