Whoami

From Dikapedia
Jump to: navigation, search

https://www.thegeekstuff.com/2009/03/4-ways-to-identify-who-is-logged-in-on-your-linux-system/

whoami command is used to print the loggedin user name.

$ whoami
john

whoami gives the same output as id -un as shown below:

$ id -un
john

whoami command will display the logged-in user name and current tty details. The output of this command contains the following columns: logged-in user name, tty name, current time with date and ip-address from where this users initiated the connection.

$ who am i
john     pts/2        2009-03-28 23:04 (dev-db-server)

$ who mom likes
john     pts/2        2009-03-28 23:04 (dev-db-server)

$ who mom hates
ec2-user pts/0        2020-06-15 05:43 (ip68-100-237-178.dc.dc.cox.net)

$ who -m

saml pts/1 2014-01-06 09:44 (:0)

$ who likes candy
saml     pts/1        2014-01-06 09:44 (:0)

$ who eats cookies
saml     pts/1        2014-01-06 09:44 (:0)
 
$ who blah blah
saml     pts/1        2014-01-06 09:44 (:0)

Warning: Don't try "who mom hates" command.

Also, if you do su to some other user, this command will give the information about the logged in user name details.