• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

whoami: command not found

by admin

The whoami command is used to display the user name with which you are currently logged in to the system. Sometimes, you may need to log in to a system and switch among different users, and you may not be sure with which user you are currently logged in. In such instances, you can use the whoami command to verify your current user name.

We can quickly view information about the current user by using the whoami command. The whoami command displays the owner of the current login session:

# whoami
root

We can view the available options of the whoami command by passing the –help option:

# whoami --help
Usage: whoami [OPTION]...
Print the user name associated with the current effective user ID.
Same as id -un.
     --help     display this help and exit
     --version  output version information and exit
GNU coreutils online help: [http://www.gnu.org/software/coreutils/]
Full documentation at: [http://www.gnu.org/software/coreutils/whoami]
or available locally via: info '(coreutils) whoami invocation'

If you encounter the below error while running the whoami command:

whoami: command not found

you may try installing the coreutils package as shown below as per your choice of distribution.

Distribution Command
OS X brew install coreutils
Debian apt-get install coreutils
Ubuntu apt-get install coreutils
Alpine apk add coreutils
Arch Linux pacman -S coreutils
Kali Linux apt-get install coreutils
CentOS yum install coreutils
Fedora dnf install coreutils
Raspbian apt-get install coreutils

whoami Command Examples

1. Display currently logged username:

# whoami

2. Display the username after a change in the user ID:

$ sudo whoami

Conclusion

The whoami command prints the name of the current, effective user. This may differ from your login name (the output of logname) if you’ve used the sudo command.

Filed Under: Linux

Some more articles you might also be interested in …

  1. doctl serverless: Manage serverless functions
  2. lrzip: command not found
  3. How to Install and configure telnet in RHEL / CentOS 5,6
  4. “git notes” Command Examples
  5. qm clone Command Examples in Linux
  6. “git send-email” Command Examples
  7. finger: User information lookup program
  8. awk Command Examples in Linux
  9. chattr Command Examples to Change File Attributes (Make files immutable)
  10. lsscsi: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright