听老歌 发表于 2011-11-21 16:02

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

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



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

我们都知道id -u显示的是你当前的uid号码,但是加上那个-n就不同了,下面我们来看看他们的区别:# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
# id -u
0
# id-un【-n显示名字而不是id号】
root
# 也就是说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

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

# id -n【发现了吧,这个-n必须得和其他参数,比如说-u,-g,-G联合使用。】
id: cannot print only names or real IDs in default format
# id -un
root
# id -gn
root
# id -Gn
root bin daemon sys adm disk wheel【输出的结果就是所属的组以及附加组】

Shell_HAT 发表于 2011-11-21 20:13

这些乱七八糟的帖子都是从哪来转过来的啊:dizzy:
http://bbs.chinaunix.net/thread-3620220-1-2.html
页: [1]
查看完整版本: 你知道你你的LOGNAME是如何来的吗? .