Skip to main content

Command referencewhoami

whoami command (Linux / bash / sh / zsh)

Linuxbashshzshuserbeginner

What it does

Print the effective user name of the current process. When people search for the whoami command linux user, they usually want whoami's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.

Print the effective user name of the current process.

Syntax

whoami [OPTION]

Common options

Flag / optionMeaning
--helpDisplay brief usage help.
--versionPrint program version information.
$(whoami)Use the result in shell command substitution.

Practical examples

Current identity

whoami

Prints the effective login name.

Conditional check

if [ "$(whoami)" = root ]; then echo privileged; fi

Checks whether the effective user is root.

Remote identity

ssh server whoami

Reports the effective remote account.

Common mistakes

  • Confusing the effective user with the original login user after sudo.
  • Using whoami when numeric IDs or group memberships from `id` are required.

FAQ

What does whoami do in Linux?

Print the effective user name of the current process.

How do I use whoami from the terminal?

Start with `whoami [OPTION]`, then choose only the options needed for the task.

What is a practical whoami example?

Try `whoami` — Prints the effective login name.

Can I use whoami in a shell script?

Yes. whoami works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.