Today we had the need to determine the initial id of a user who logged onto a Linux box via SSH and executed the su command. When the su command is issued the effective user is changed and whoami or id commands will report that new user id instead.
For anyone who is interested, that is what we came up to put the initial user id into a variable named ${LOGIN_USER}
LOGIN_USER=`who -m`; LOGIN_USER=${LOGIN_USER%% *}
or alternatively
LOGIN_USER=`who -m | cut -d' ' -f1`