LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

whoami

Print current effective username

TLDR

Print the current username
$ whoami
copy

SYNOPSIS

whoami [--help] [--version]

DESCRIPTION

whoami prints the username associated with the current effective user ID. It's equivalent to id -un.This is useful in scripts to determine which user is running the script, especially when the script might be run via sudo or after using su to switch users.Unlike who am i which shows the login name from utmp, whoami shows the effective user ID name, which may differ after sudo or su.

PARAMETERS

--help

Display help and exit
--version
Display version and exit

INSTALL

sudo apt install coreutils
copy
sudo dnf install coreutils
copy
sudo pacman -S coreutils
copy
sudo apk add coreutils
copy
sudo zypper install coreutils
copy
brew install coreutils
copy
nix profile install nixpkgs#coreutils
copy

CAVEATS

After sudo, whoami shows the target user (usually root), not the original user. Use logname or who am i to get the original login name.The command shows the effective user ID. In setuid programs, this may differ from the real user ID.

SEE ALSO

who(1), id(1), logname(1), users(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid