你知道你你的LOGNAME是如何来的吗?

本文详细介绍了Linux中id命令的使用方法及其参数含义,特别是-n选项的功能,并通过实例展示了如何查看用户的UID、GID及所属组。

你知道你的LOGNAME是如何来的吗?我之所以这样问,也是因为刚刚才发现这其间的小秘密。

我们都知道id -u显示的是你当前的uid号码,但是加上那个-n就不同了,下面我们来看看他们的区别:

[root@SYS ~]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@SYS ~]# id -u
0
[root@SYS ~]# id-un【-n显示名字而不是id号】
root
[root@SYS ~]#

也就是说LOGNAME就是通过id -un来显示的。

Ps:

id小节

=========================================================================

id - print user identity

 -a     ignore, for compatibility with other versions

-r, --real
              print the real ID instead of the effective ID, with -ugG

-Z, --context
              print only the security context of the current process

[root@SOR_SYS ~]# id -a
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@SOR_SYS ~]# id -u
0
[root@SOR_SYS ~]# id -g
0
[root@SOR_SYS ~]# id -G
0 1 2 3 4 6 10

[root@SYS ~]# id -n【发现了吧,这个-n必须得和其他参数,比如说-u,-g,-G联合使用。】
id: cannot print only names or real IDs in default format

[root@SYS ~]# id -un
root
[root@SYS ~]# id -gn
root
[root@SYS ~]# id -Gn
root bin daemon sys adm disk wheel【输出的结果就是所属的组以及附加组】

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值