How to make sudo use your login name

This is being tossed out there as a handy reference to sysadmins around the world.
Sudo is a magnificient tool for Unix / Linux based systems that allows a single command to be executed as the root / privileged user. The advantage is that the command is logged to the syslog, and access to sudo-managed tools can be tightly controlled via /etc/sudoers.
One problem that comes up a lot is that logged activities on a host will show up as ‘root’ when sudo is used to invoke them, when what you really want is to know who initiated the command.
The sudoers file can include an option that tells sudo to not reset the users login name when escalating priveleges. The option is:

Defaults        !set_logname 

Putting this option in sudoers will make it so RCS checkins and other tasks will log as the user who invoked the sudo, not root.

About

A wandering geek. Toys, shiny things, pursuits and distractions.

View all posts by

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.