Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have added the below lines to /etc/sudoers.d/my_sudoers

Defaults    mail_always
Defaults    mailto=""

I get an email every time sudo is run

How can i modify this so I only receive emails when particular people run sudo (Everybody except 2 users)


share|improve this question

migrated from Apr 12 '13 at 0:55

This question came from our site for professional and enthusiast programmers.

up vote 4 down vote accepted

This is straightforward; Defaults can apply to specific users (and other limitations), and user aliases can be constructed with negated matches. Something along these lines:

User_Alias NoMail = goodboy, goodgirl
User_Alias MailUsers = ALL, !NoMail

Defaults           mailto=""
Defaults:MailUsers mail_always
Defaults:NoMail    !mail_badpass
share|improve this answer

I'm not to sure on the syntax but wouldn't creating an if statement help SUDO if (name = NAME1, NAME2,) { do nothing } else { email }

share|improve this answer

Assuming that only the two users exist in the sudoers file, the following will achieve what you want:

Defaults mailto="", mail_no_user

Otherwise, you'll probably need to resort to filtering your emails.

share|improve this answer
This didn't work. There must be another option without filtering emails. – ubuntu101010101 Apr 11 '13 at 12:27
I didn't realize that mail_no_user is on by default. – devnull Apr 11 '13 at 12:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .