Linux Command
whoami
Print the name corresponding to the currently valid user ID
Summary
whoami [OPTION]...
The main purpose
Options
--help Display help information and exit.
--version Display version information and exit.
return value
Returning 0 indicates success, returning a non-zero value indicates failure.
example
[root@localhost ~]# whoami
root
Notice
-
This command is equivalent to
id -un. -
Pay attention to distinguishing the two commands
whoamiandlogname; for example, we opened the terminal as userrootand then switched to useruser2. At this time,whoamireturns the current useruser2, andlognamereturnsroot. You can verify it by yourself. -
This command is a command in the
GNU coreutilspackage. For related help information, please seeman -s 1 whoami,info coreutils 'whoami invocation'.


