Skip to content

whoami command

Print the current user name.

On this page

Syntax

whoami

Provided by the coreutils package. Run man whoami for the full manual.

Common options

OptionWhat it does
idAlso show the UID, GID and groups
whoUsers logged in now
wLogged-in users and what they run

Examples

  1. Current user

    whoami
  2. User and groups

    id
  3. Check if a script runs as root

    [ "$(id -u)" -eq 0 ] || { echo "Run as root"; exit 1; }
  4. Who is logged in

    w

whoami guides

← All Linux commands · Suggest a fix

Back to top