Search code examples
bashshellubuntu

Get current user on root script ubuntu


I write a script for the network dispatcher in /etc/NetworkDispatcher/dispatcher.d/. How can I get the current logged user?

I already tried these commands :

$USER
$LOGNAME

Thank you for help.


Solution

  • You could also use "last":

    $ last | grep "logged in"