Sebastian Thomschke
IT Berater – Java, J2EE, WebSphere Portal, Lotus Domino
-
Determine the user who logged on via SSH
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`
Leave a reply


Looking for a high performer for your next IT project?
English
Deutsch
Recent Comments