3 of 5
added 399 characters in body
pa4080
  • 29.9k
  • 10
  • 89
  • 162

How do I find 'who am I' on Ubuntu Desktop?

In Ubuntu Server 16.04, when I type who am i it returns an output similar to who -m:

user@UbuntuServer:~$ who am I
user  pts/1        2018-05-09 00:30 (192.168.1.100)

user@UbuntuServer:~$ who -m
user  pts/1        2018-05-09 00:30 (192.168.1.100)

In my Ubuntu Desktop 16.04 who am i and who -m do nothing. How do I make this work?

enter image description here



What I actually want is to parse the output of who -m (who am i) within a script when this script is executed by sudo to find the username of the user that runs the script:

user@UbuntuServer:~$ cat who.sh 
#!/bin/sh
whoami
echo $USER
who -m | awk '{print $1}'

user@UbuntuServer:~$ sudo ./who.sh 
root
root
user
pa4080
  • 29.9k
  • 10
  • 89
  • 162