How to Use the Linux whoami and id Commands to View User Information

When managing a Linux server environment, particularly a shared system where multiple users are executing commands simultaneously, it is occasionally necessary to verify exactly which user account you are currently logged in as, or to determine the numerical ID associated with your permissions.

Linux provides two fundamental, incredibly fast command-line utilities specifically designed for this purpose: whoami and id.

Using the whoami Command

The whoami command is the simplest identity tool available in Linux. It performs one single function: it prints the username associated with your current effective terminal session.

To use it, simply type:

whoami

If you are logged into your standard desktop account, it will print your name (e.g., alex). However, if you recently executed the su - command to elevate your privileges and switch to the superuser, running whoami will instantly return root, reminding you that you are currently operating with dangerous, system-wide privileges.

Using the id Command for Deep Details

While knowing your username is helpful, the Linux operating system actually manages permissions using numbers, not names. To view the granular technical details of an account, use the id command.

Typing the command by itself outputs the data for your current session:

id

The terminal will output a string of data formatted like this:
uid=1000(alex) gid=1000(alex) groups=1000(alex),27(sudo),46(plugdev)

This output tells you three critical pieces of information:

  • uid (User ID): The unique numerical identifier for your specific user. Standard users typically start at 1000. The root user is always 0.
  • gid (Group ID): The numerical identifier of your primary group.
  • groups: A list of every supplementary permission group your account belongs to. In the example above, you can instantly see that the user belongs to the sudo group, meaning they possess administrative privileges.

You can also append a username to the end of the command to view the numerical identifiers and group memberships of a completely different user without needing to log in as them:

id serveradmin

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.