In this guide, we will explore the whoami command, which is used to print the current user name. This command works on Linux, macOS, WSL, and any UNIX environment.

How to Use the whoami Command

To print the user name currently logged in to the terminal session, simply type whoami and press Enter. Here’s an example:

$ whoami
john_doe

Screenshot

Note: The whoami command should not be confused with the who am i command, which provides more detailed information.

Now you know how to use the whoami command to quickly retrieve the current user name. Give it a try on your own system and see the result!