In this article, we will learn about how to find your username using the whoami command in Linux. As its name suggests, the whoami
command prints the user name of the effective user ID. In other words, it displays the name of the currently logged-in user.
whoami Command in Linux
The syntax for the whoami
command is this:
$ whoami [oprions]
To display the name of the currently logged user, if you are using the following command:
$ whoami
When you are switching to another user with the su
command. You can verify using whoami
command whether the user is logged in or not.
The whoami
command can accept two arguments:
- -h (–help) – Display this help and exit.
- -V (–version) – Output version information and exit.
Conclusion
The whoami command is a compound of the words “Who am I?” and prints the name of the user associated with the current effective user ID.
If you have any questions, feel free to leave a comment.
Related Posts: