whoami – print your username

whoami command

whoami is a one of the basic Unix commands with a single purpose: it confirms your effective user id. Put simply, it shows you your username.

whoami command

There are no parameters to specify, so just type whoami and it will output a username (my username is greys):

greys@xps:~ $ whoami
greys

Username vs Effective Username

You may hear about effective usernames. That’s because in Unix and Linux it’s possible to use commands like su command and sudo command to become a different user and to execute commands under another user’s identity.

For instance, sudo helps you become root user. So after running sudo command as shown below, my effective username will become root:

greys@xps:~ $ sudo -i
[sudo] password for greys: 
root@xps:~ # whoami
root

See Also