whoami

Whoami is a Unix command that prints the command invoking user's user name. The term derives from the English question Who am I? (in German " Who am I? " ) from. Especially in 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 in older shells that have not spent in the prompt with the username, could occur after only a few su confusion in the user, under which user name he is working on. A quick call to the whoami command is enough to be sure of his identity.

Whoami is part of the GNU core utilities; the version was written by Richard Mlynarik for the GNU project.

To be used under Unix

Modern Unix shells set when logging in the environment variable $ USER, which is usually issued in the command line prompt. However, this includes the user name that belongs to the effective UID, and not to the real. With a call to su without parameters, for example, only the real UID, effective, however, does not change. Therefore, it may here come to confusion:

User @ host $ whoami user user @ host $ su Password: user @ host $ whoami root user @ host $ exit user @ host $ whoami user A call to su with the - on the other hand also changes the effective UID, because a new login shell is started ( and therefore the value of the environment variable $ USER is other ). Here the call to whoami is unnecessary in general, because the real user ID is already available in the prompt:

User @ host $ whoami user user @ host $ su - Password: root @ host $ whoami root root @ host $ logout user @ host $ alternatives

Use the Unix id command, the invoked with the- un posing the same issues as whoami, whoami is now obsolete.

Whoami on other platforms

Also for other ( multi-user ) operating systems developed programs with the same name and analog functions.

Novell NetWare

Novell NetWare also provides the function " Who am I " is available. For DOS based clients supply whoami.exe:

Z: \> Whoami.exe You are attached to server- user ZDL S311 connection 4 S311 server 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 have the program Whoami.exe, which provides similar functionality.

819135
de