• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Script help (sudoed user id)

Khyron320

Senior member
Im trying to get the script to mark who is running the command. But it will always be from a sudo su - USER123 account.

ps -ef |grep grep
will show me the pts session and i can ID the user that way.... but it seems like such a hack is there a value stored somewhere to show what pts is in use and from what user?

There has to be a simpler way.

you cant use
echo $USER when your sudoed it shows the account you promoted too not your own.
 
whoami doesnt work. These users do "sudo su -" which loads the env variables of the user you Sudoed too

Also
echo $SUDO_USER does not work in this case.

I came up with this to do it:

REALUSERID=`TTYTEST=$(ps | awk '{print $2}' |tail -1); ps -ef |grep "$TTYTEST$" |awk '{print $1}'`
 
no, not:

whoami

who am i

note the spaces in between "who" "am", and "i". I tried it with sudo and it worked for me...
 
Back
Top