📅  最后修改于: 2023-12-03 14:43:57.110000             🧑  作者: Mango
在Linux操作系统中,whoami命令被用于显示当前登录用户的用户名。它在用户控制台输入该命令后会立即返回登录该控制台的用户名称。
whoami [-a, --help, --version]
$ whoami
alice
输出为当前登录终端的用户名:alice。
$ whoami -a
root tty1 Oct 20 16:33
alice Oct 20 16:33 (:0)
输出中第一个用户是root,终端为tty1。第二个用户为alice,终端为:0。
$ whoami --help
Usage: whoami [OPTION]...
Print the user name associated with the current effective user ID.
Same as id -un.
-a, --all print all information in the following format:
login process name PID type tty device date time
--help display this help and exit
--version output version information and exit
Report who you are.
$ whoami --version
whoami (GNU coreutils) 8.22
Packaged by Gentoo (8.22-r2 p1.1)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
以上就是关于Linux中的whoami命令的简介和使用方法。