运行流程.为什么显示uid编号而不是用户名?

Ant*_*sov 25 linux uid

ps -eaf

..

kude     22593 12078  0 09:06 ?        00:00:02 smbd -D
hasi     22929 12078  0 09:12 ?        00:00:00 someprog.pl
root     22950    43  0 Sep08 ?        00:00:19 [nfsiod]
root     24558    43  0 Sep09 ?        00:00:28 [pdflush]
root     25320     1  0 00:00 ?        00:00:01 /usr/bin/atop -a -w /var/log/atop/atop_20110916 600
1466     25757 12078  0 10:12 ?        00:00:00 smbd -D
root     26752 12078  0 10:32 ?        00:00:01 smbd -D
Run Code Online (Sandbox Code Playgroud)

..

id username2

uid = 1466(username2)gid = 513(DomainUsers)groups = 513(DomainUsers)

LDAP中的所有用户(/etc/nsswitch.conf都是正确的,一切都正确 - 但只有这个用户不显示)

为什么显示uid号码(1466)而不是用户名?

Ray*_*oal 38

用户名ps -ef(POSIX)或ps aux(BSD衍生物)中列出了8个字符的限制. 选项说明

我在Mac和Linux机器上搜索了手册页,并没有看到那里记录的限制.

这个问题经常出现在论坛上,其中包含8个字符的限制作为答案.

终于绊倒在此页面中,报道对Debian中的"错误",但收盘为不是一个错误.他们引用了这个页面,它也说明了当名称太长时POSIX和UNIX标准如何要求回退到uid.也不是来自实际的POSIX标准.

我不知道这是否具有权威性,但它确实解释了您使用9个字符的用户名所看到的行为.:)

也许其他人可以发布更具权威性的链接答案?


ano*_*ard 11

正如Ray Toal所提到的,它仅限于8个字符的限制.这不是一个bug,而是Ray提到的标准的一部分.如果你查看ps(部分procps包装)的源代码,其中一条评论说

The Open Group Base Specifications Issue 6 (IEEE Std 1003.1, 2004 Edition)  
requires that user and group names print as decimal numbers if there is
not enough room in the column, so tough luck if you don't like it.

The UNIX and POSIX way to change column width is to rename it:
  ps -o pid,user=CumbersomeUserNames -o comm
The easy way is to directly specify the desired width:
  ps -o pid,user:19,comm
Run Code Online (Sandbox Code Playgroud)

如果检查链接 的部分STDOUT它说,字段(用户,RUSER,,R-基团,如果它能够获得和场宽度允许,或十进制表示以其他方式)将打印.
用户和组名称字段宽度限制为8的原因可能是遗留支持,但这只是猜测.