whoami Command: Find the Current User in Linux

Find information about your current Linux user account

When working in the command line, it's not always clear which user account you're logged in to. For example, when working with an application that requires you to log in as a different user, or when you switch users and lose track of whose credentials are currently active. The whoami command shows you which user account you're logged in to from a terminal window. Here's how to use the whoami command and the id command to find out the currently logged in user.

Person using Linux on a laptop
Lifewire / Elise Degarmo 

Use whoami to Display Your Username

To use the terminal window to display the user you're actively logged in as, type the following command:

The output of the above command shows the current user, like this:


To quickly see how this works with another user account (if you haven't made any other users in Linux), use the sudo command to log in as root:

Then, if you run the whoami command again, you'll be told that you're root.

How to Do It With id -un

In a strange circumstance where whoami isn't installed, there is another command you can use to display your current username.

The result is exactly the same as the whoami command, so in this example, it would display jacob.

The id command can show more than the current user. It can also show the user id, group id, and groups to which the user belongs. For example, to show only the effective group the user belongs to, type the following:

The above command only shows the group id. It doesn't show the group name. To show the effective group name, execute this command:

You can display every group id that a user belongs to by entering this:

The above command only shows the group ids. You can also use the Linux id command to display the group names:

If you want to display your user id without the username, run the following command:

More Information

You can use the --help switch with either whoami or id to find the current man page for each program.

To see the current version of id or whoami, use the following commands: