Difference Between “whoami” And “who am I”

We are going to see the following example, in the we connect to unix-box as a nominal user and we make a su command to another user

 
login as: anton
Using keyboard-interactive authentication.
Password:
Last login: Fri Nov 23 08:39:43 2018 from 10.201.91.166
Oracle Corporation      SunOS 5.11      11.3    June 2018
anton@houston:~$ whoami
anton
anton@houston:~$ who am I
anton     pts/1        Nov 29 13:00    (x.x.x.x)
anton@houston:~$ su - dbowner
Password:
Oracle Corporation      SunOS 5.11      11.3    June 2018
dbowner@houston:~$ whoami
dbowner
dbowner@houston:~$ who am I
anton     pts/1        Nov 29 13:00    (x.x.x.x)
dbowner@houston:~$ # ********* do su one more time  *********
dbowner@houston:~$ su - dbowner
Password:
Oracle Corporation      SunOS 5.11      11.3    June 2018
dbowner@houston:~$ whoami
dbowner
dbowner@houston:~$ who am I
anton     pts/1        Nov 29 13:00    (x.x.x.x)

You can execute it as many times as you want “who am I” will always return the user with the one you have connected to the system and whoami will only return the user with whom you are working at a given moment.

 
HTH – Antonio NAVARRO

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s