Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

The title says it all. How can I configure sudo to prompt for password and show the executed command?

Rationale: if something gets aliased in the shell or I end up executing a function sudo instead of the program, I would still like to see the actual sudo (i.e. /usr/bin/sudo on Ubuntu) is going to execute before I do it. This is mostly for security reasons, i.e. I would configure this only for certain types of impersonation via sudo.

Bonus points: if this can be configured, is it also possible to use it with NOPASSWD: inside /etc/sudoers?

share|improve this question
It appears that the default action is to write the command to /var/log/auth.log. So you could write a bash function to parse the last sudo command by your UID. Downside is that you have to be a member of the adm group to view the auth.log file. Probably an enhancement request to the package maintainer. – Justin Andrusk Jun 11 '13 at 2:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.