How to see actual username who logged in as root with sudo

Hi,

Thanks for looking at this.

I would like to know who is actually logged in as sudo root ?
ex: i have many users given sudo rights as root, and all of they are making changes as root and it is difficult for me to know who did what ,a s it shows as rot only.

Is there any way to find or any environment variable shows actual user information ?

thanks
KRR

All commands run as sudo are logged in the log file /var/log/messages.
Have a great work Mr. Ramana.

Cheers,
Sreedhar

1 Like

No this didn't work for me.
Ex: i have seen grep myusername /var/log/messages, even i have done many tasks as root, ti didn't show any.

Anyways thanks for your reply.

Don't know what O/S you have.

Try:

logname
1 Like

Dear Ramana,

You might not be able to see because in your system sudo log is not configured.
You have to configure in syslog.conf to see the details. So please add the below lines in /etc/syslog.conf file and restart syslog.

# This logs successful and failed sudo attempts to the file /var/log/sudo.log
local2.debug /var/log/sudo.log

You add the above configuration in syslog.conf and restart syslog ... and make sure to touch the /var/log/sudo.log file and give full permissions. So that you can see these logs.

Cheers
Sreedhar

1 Like