Now that you know the basics of
sudo, let’s consider a configuration that trips up even experienced system administrators. Sometimes you want to prevent users from executing specific commands but give them access to every other command. The sudoers documentation says that you can do this using the exclamation point (
!) as a negation character, but that’s not entirely effective. Because this is a popular method, however, I’ll discuss how it works, and then demonstrate how your users automatically get root if you use it.
Start by defining command aliases that contain the forbidden commands. One popular exclusion is
su. Another common exclusion is user shells, because if you execute a shell as a user, you become ...