wer bin ich
whoami is a Unix command that outputs the username of the user calling the command. The term is derived from the English question Who am I? (in German “Who am I?”). Especially with multi-user systems such as Unix and related derivatives , users are able to change their identity, for example with the Unix command su
or sudo . Especially with older shells that did not include the user name in the prompt, the user could find out su
which user name he was currently working under after just a few confusions. A short call of the whoami
command is enough to be sure of your identity.
whoami
is part of the GNU Core Utilities ; the version was written by Richard Mlynarik for the GNU project .
Use under Unix
Modern Unix shells set the environment variable when logging on , which is usually also output in the command line prompt. However, this contains the user name that belongs to the effective UID and not the real one. If you call without parameters, for example, only the real UID changes, but not the effective one. This can lead to confusion:
$USER
su
benutzer@host $ whoami
benutzer
benutzer@host $ su
Password:
benutzer@host $ whoami
root
benutzer@host $ exit
benutzer@host $ whoami
benutzer
Calling su
with the parameter also -
changes the effective UID, because a new login shell is started (and the value of the environment variable $USER
is therefore also different). Calling is generally whoami
superfluous here because the real username is then already in the prompt:
benutzer@host $ whoami
benutzer
benutzer@host $ su -
Password:
root@host $ whoami
root
root@host $ logout
benutzer@host $
Alternatives
The Unix command id
that outputs -un
the same output when called with the parameters whoami
is whoami
now obsolete.
whoami on other platforms
Programs with the same name and an analogous range of functions were also created for other (multi-user) operating systems.
Novell NetWare
Also, Novell NetWare , the "Who am I" function. For DOS -based clients there is whoami.exe :
Z:\>WHOAMI.EXE You are user ZDL attached to server S311, connection 4. Server S311 is running NetWare v3.12 (25 user). Login time: Saturday November 22, 2008 2:53 pm
Microsoft Windows
The Windows 2000 Resource Kit , Windows Vista , Windows 7 and Windows Server 2008 all have the Whoami.exe program , which provides a similar functionality. Various information, e.g. B. Logon-ID, UPN or FQDN as well as lists of users, groups and authorizations can be determined in various formats (e.g. CSV ).
PS C:\> whoami /FQDN CN=Mustermann\, Max,OU=Users,OU=4711,OU=42,OU=wikipedia,DC=de,DC=wikipedia,DC=org
PS C:\> whoami /USER /FO CSV "Benutzername","SID" "wikipedia\Mustermann","S-1-5-21-123456789-1234567890-1234567890-12345"
MorphOS
WhoAmI as part of AmiTCP
Ram Disk:> whoami morphosuser
Web links
-
whoami(1)
: display effective user ID - OpenBSD General Commands Manual -
whoami(1)
: Print the effective user ID - Debian GNU / Linux executables or shell commands man page - whomai Microsoft Windows 2000 Resource Kit tool (English)
- Description of the whoami.exe command under Microsoft Windows in the MSDN
Individual evidence
-
↑
id
- Open Group Base Specification