SyntaxHighlighter JS

2018-10-25

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

logname 

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)

Output:
My sudo id is oracle and my login id is juttayaya



Reference:https://stackoverflow.com/questions/4598001/how-do-you-find-the-original-user-through-multiple-sudo-and-su-commands

3 comments:

  1. Keeping up with emerging technologies is seamless with NotePadTech, which provides accurate news, expert insights, and trending updates. The platform equips readers with essential information, helping them understand innovations and anticipate shifts in the digital and tech landscape.

    ReplyDelete
  2. Readers looking for accurate reporting will value TechOverFly
    , which provides detailed analysis and breaking updates in business, politics, and technology. The platform ensures audiences remain informed about market trends, policy shifts, and industry developments.

    ReplyDelete

  3. Comprehensive and timely, FoxNewsPaper provides readers with accurate reporting across politics, business, entertainment, and global news. The platform delivers breaking updates and insightful analysis, keeping audiences informed and engaged with the latest developments.

    ReplyDelete