[xubuntu-users] Detecting login name after su
Peter Flynn
peter at silmaril.ie
Fri Oct 4 20:03:52 UTC 2013
On 10/04/2013 08:34 AM, Jan Henke wrote:
> Hi,
>
> the command 'w' lists all currently logged in users together with the
> source of the login. You can parse that output to look for you local
> machine (IP address or reverse DNS name), then you have the user name.
Hah! That's it, thanks...I had completely forgotten about it.
$ ssh xyz at foo.bar.com
xyz at foo.bar.com's password:
Last login: Thu Oct 3 23:56:16 2013 from blort.bar.com
$ sudo su -
[sudo] password for xyz:
# w -u | grep 'w -u$' | awk '{print $1}'
xyz
#
gives the username you originally logged in as (here 'xyz').
///Peter
More information about the xubuntu-users
mailing list