Print the name corresponding to the currently valid user ID
whoami [OPTION]...
--help Display help information and exit.
--version Display version information and exit.
Returning 0 indicates success, returning a non-zero value indicates failure.
[root@localhost ~]# whoami
root
id -un
.whoami
and logname
; for example, we opened the terminal as user root
and then switched to user user2
. At this time, whoami
returns the current user user2
, and logname
returns root
. You can verify it by yourself.GNU coreutils
package. For related help information, please see man -s 1 whoami
, info coreutils 'whoami invocation'
.