Permissions, users and access

Command whoami

Show current user

Linux · Bash examples · commands run on the selected server

When to use whoami

Use whoami to identify the effective account in the current shell. Check it after switching users or entering a maintenance session before writing configuration, changing permissions or running account-specific commands.

Syntax

whoami

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

No arguments
Show the effective user name of the current process.
--help
Show GNU whoami help.

Usage examples

Show your identity

whoami

The effective username is printed.

Compare with numeric UID

id -u

The effective numeric user ID provides an unambiguous identity check.

Check launch from deploy

sudo -u deploy whoami

The printed username is that of the explicitly selected deployment account.

Notes and limitations

  • The effective user may be different from the original login user.
  • If a complete set of UID and groups is required, use id.

Common questions and troubleshooting

Is whoami the original SSH login name?

Not necessarily. It reports the effective execution identity, which can change through account-switching tools.

Why use id as well as whoami?

A username alone omits supplementary groups and numeric identities, which are often necessary when diagnosing permission problems.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man whoami.