In this tutorial we will learn about whoami command in Linux / Unix system. We will also read about its use and advantage. Its best use is in shell like sh,ash and ksh where username is not seen in command prompt.
Introduction Of whoami Command
The whoami command print the user name associated with user id which is login in current session.It is similar to command
The whoami command is available in Linux and Unix like Operating Systems.
whoami Command Use And Advantage
whoami command , simply run the command
whoami . It will show the user name of currently working username in current session.
whoami command is also available in Windows (Read this Microsoft link for information)
See given below figure: whoami command in Linux bash shell
Advantage Of whoami Command
As you have seen in above figure, in BASH shell , we can easily see the username.In some shell, you will only see $ sign .It means non-root user login in shell terminal.
If in your terminal,if you see only $ sign. You can not confirm you are login with which user name. In that case you can use
I have selected Bourne Shell (sh) and korn shell (ksh) to illustrate the example.
Notice the $ sign in both Bourne Shell (sh) and korn shell (ksh) .
Note: The whoami command only has available two options that is ‘help’ and ‘version’.
Find the given below commands.
whoami --help and whoami --version