SyntaxHighlighter JS


Get the original username of sudo

For auditing and logging purposes, I needed to get the original Unix login username and not the sudo account name.

The Unix command to get the original login username is


With the logname command, the operator can su and sudo to various accounts and it will still display the original login.

To try it on a Unix prompt

sudo su - oracle
echo My sudo id is $(whoami) and my login id is $(logname)

My sudo id is oracle and my login id is juttayaya


No comments:

Post a Comment