-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
21 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,40 @@ | ||
whoami | ||
=== | ||
|
||
打印当前有效的用户名称 | ||
打印当前有效的用户ID对应的名称 | ||
|
||
## 补充说明 | ||
|
||
**whoami命令** 用于打印当前有效的用户名称,相当于执行`id -un`命令。 | ||
|
||
### 语法 | ||
## 概要 | ||
|
||
```shell | ||
whoami(选项) | ||
whoami [OPTION]... | ||
``` | ||
|
||
### 选项 | ||
## 主要用途 | ||
|
||
- 打印当前有效的用户ID对应的名称。 | ||
|
||
## 选项 | ||
|
||
```shell | ||
--help:在线帮助; | ||
--version:显示版本信息。 | ||
--help 显示帮助信息并退出。 | ||
--version 显示版本信息并退出。 | ||
``` | ||
|
||
### 实例 | ||
## 返回值 | ||
|
||
返回0表示成功,返回非0值表示失败。 | ||
|
||
## 例子 | ||
|
||
```shell | ||
[root@localhost ~]# whoami | ||
root | ||
|
||
[root@localhost ~]# id -un | ||
root | ||
``` | ||
|
||
### 注意 | ||
|
||
1. 该命令等价于 `id -un`。 | ||
2. 注意区分 `whoami` 和 `logname` 这两个命令;比如我们以用户 `root` 打开的终端,然后切换到了用户 `user2`。此时, `whoami`返回的是当前用户 `user2`, `logname` 返回的是 `root`,大家可以自行实践验证一下。 | ||
3. 该命令是`GNU coreutils`包中的命令,相关的帮助信息请查看`man -s 1 whoami`,`info coreutils 'whoami invocation'`。 | ||
|
||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ --> | ||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ --> |