[xubuntu-users] Detecting login name after su
Joshua O'Leary
jmoey139 at gmail.com
Sat Oct 5 16:14:03 UTC 2013
You could pass the username as a parameter to the script at runtime:
myscript.sh `whoami`
Accessing it with the $1 (or whatever number the parameter is) in the
script.
'logname' may also be an option but I think it needs to be running in a
tty/vt to work.
Joshua
On 04/10/13 08:34, 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.
>
> Regards
> Jan
>
> Am 04.10.2013 00:57, schrieb Peter Flynn:
>> On 10/03/2013 08:58 PM, Lutz Andersohn wrote:
>>> I think the users command always prints the original user. I logged on as some
>>> user, did a sudo -i, called users again and it gave me my original user name.
>>> also works with sudo su -
>> Indeed it does, thanks. But with potentially many users logged in, how
>> do I detect which one is the account I "came from"?
>>
>> ///Peter
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/xubuntu-users/attachments/20131005/7b253161/attachment.html>
More information about the xubuntu-users
mailing list