Linux基础命令[19]-id

1. id 命令说明

id:显示真实有效的用户ID(UID)和组ID(GID),十分方便,不用再查找 /etc/groop(里面有全部用户的信息)。基本信息如下:

Usage: id [OPTION]... [USERNAME]
Print user and group information for the specified USERNAME,
or (when USERNAME omitted) for the current user.

  -a              ignore, for compatibility with other versions
  -Z, --context   print only the security context of the current user
  -g, --group     print only the effective group ID
  -G, --groups    print all group IDs
  -n, --name      print a name instead of a number, for -ugG
  -r, --real      print the real ID instead of the effective ID, with -ugG
  -u, --user      print only the effective user ID
      --help     display this help and exit
      --version  output version information and exit

Without any OPTION, print some useful set of identified information.

Report id bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'id invocation'

参数如下:

选项作用
-a忽略该命令,仅为了与其他版本兼容
-Z仅显示当前用户的安全内容
-g显示用户所属群组的ID
-G显示用户所属所有群组,包括附加群组的ID
-n显示用户,所属群组或附加群组的名称
-r显示实际的ID
-u显示当前用户ID

2. id 命令语法

id [OPTION]... [USERNAME]

3. id 命令示例

3.1 不加参数

不加用户名时,显示当前用户的信息,包括 uid gid groups

id

加用户名时,显示的是该用户的 uid gid groups

id admin

在这里插入图片描述

3.2 -u/-g/-G(用户、组、所属组)

这三个参数配合 -n 使用时,会显示名称,也可以指定用户

id -u
id -un
id -un admin

在这里插入图片描述

3.3 -gr/-Gr/-ur(有效ID)

[root ~]$ id -gr
1101
[root ~]$ id -Gr
1101
[root ~]$ id -ur
1101
[root ~]$ id -ur admin
200
[root ~]$ id -Gr admin
200 10
[root ~]$ id -gr admin
200

在这里插入图片描述

4. 总结

id:用于显示当前或指定用户的 UID GID。

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值