在linux中,查询用户信息的命令有:id、who、who am i、whoami,接下来我们看一下这些命令的区别。
至于这些命令下涉及的相关参数请移步到其他博主的文档学习。
1、id命令
用man命令查看id命令的帮助信息,其部分信息如下:
#man id
NAME
id - print real and effective user and group IDs
DESCRIPTION
Print user and group information for the specified USER, or (when USER omitted) for the current user.
通过man命令,可以看出id命令的作用是:查询有效用户的用户id、组id信息。
例如:当前登录用户是root用户,在root用户下使用id命令,此时有效用户为root用户,其效果如下:
[root@localhost ~]# id
uid=0(root) gid=0(root) 组=0(root) 环境=unconfined_u:unconfined_r:unconfined_t:s