Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running processes. Why displayed uid number instead username? [closed]

Tags:

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 

..

id username2

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

All users in LDAP (/etc/nsswitch.conf is correct, all is correct - but only this user do not show)

Why displayed uid number (1466) instead username?

like image 945
Anton Shevtsov Avatar asked Sep 16 '11 06:09

Anton Shevtsov


People also ask

Does UID mean user ID?

Associated with each user name is a user identification number (UID). The UID number identifies the user name to any system on which the user attempts to log in. And, the UID number is used by systems to identify the owners of files and directories.

What is UID of a process?

The real uid is the id of the user that launched a process. The effective uid typically is the same as the real uid. It is different only if: the executable had the set-uid bit set, and the executable owner is different than the user calling it. or if a set-uid process calls setuid(2).

How do I show all processes running by a particular user?

To see only the processes owned by a specific user on Linux run: ps -u {USERNAME} Search for a Linux process by name run: pgrep -u {USERNAME} {processName} Another option to list processes by name is to run either top -U {userName} or htop -u {userName} commands.


2 Answers

There is an 8-character limit for usernames to be listed in ps -ef (POSIX) or ps aux (BSD-derivatives). Explanation of options

I've searched man pages on both Macs and Linux boxes and did not see that limit recorded there.

The question does routinely appear on forums with the 8-character limit as the answer.

I did finally stumble upon this page in which the "bug" was reported against Debian but closed as being not a bug. They reference this page which also makes a claim about how POSIX and UNIX standards require falling back to uids when names are too long. Also not from the actual POSIX standard.

I don't know if this is authoritative, but it does explain the behavior you are seeing with a 9-character username. :)

Maybe someone else can post an answer to a more authoritative link?

like image 111
Ray Toal Avatar answered Oct 27 '22 09:10

Ray Toal


As Ray Toal mentions it is restricted to 8-character limit. This is not a bug but part of the standard again as mentioned by Ray. If you check the source code of ps (part of procps package) one of the comments says

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 

If you check the link in the section STDOUT it says that the fields (user, ruser, group, rgroup)will printed if it can be obtained and the field width permits, or a decimal representation otherwise.
The reason why user & group name field widths are restricted to 8 could be for legacy support but that is only a guess.

like image 42
another.anon.coward Avatar answered Oct 27 '22 09:10

another.anon.coward