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
whoamiSquare 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
Usage examples
Show your identity
whoamiThe effective username is printed.
Compare with numeric UID
id -uThe effective numeric user ID provides an unambiguous identity check.
Check launch from deploy
sudo -u deploy whoamiThe 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.