Linux provides different tools to identify current and related users. whoami
is one of the command that is used to display information about the current user.
Linux提供了不同的工具来识别当前用户和相关用户。 whoami
是用于显示有关当前用户信息的命令之一。
打印当前用户 (Print Current User)
We can print current user with whoami
command like below.
我们可以使用whoami
命令打印当前用户,如下所示。
使用我是谁(Use who am i)
Another usage option of the whoami
command is using it separately. So we can simply write who am i
into the terminal like in English language and we will get detailed information about the current user like below.
whoami
命令的另一个用法选项是单独使用它。 因此,我们可以像英语一样简单地在终端中输入“ who am i
如下所示,我们将获得有关当前用户的详细信息。
$ who am i
印刷版(Print Version)
I know it is not important but we can also print the version of the whoami
command with the --version
option like below.
我知道这并不重要,但是我们也可以使用--version
选项打印whoami
命令的--version
如下所示。
$ whoami
打印当前登录的用户 (Print Currently Logged In Users)
We can also print currently logged in users into a Linux system with w
command. This command will also provide information like TTY ofthe user , Login time, idle and CPU usage too.
我们还可以使用w
命令将当前登录的用户打印到Linux系统中。 此命令还将提供诸如用户的TTY,登录时间,空闲和CPU使用率之类的信息。
$ w
省略标题(Omit The Header)
While printing currently logged in users we can remove the header part ot the user list. We will use -h
option.
在打印当前登录的用户时,我们可以删除用户列表的标题部分。 我们将使用-h
选项。
$ w -h
翻译自: https://www.poftut.com/linux-whoami-command-tutorial-find-current-user/