Linux: Running Processes Display UID instead of Username

Running the command ps to display a list of currently running processes may display a UID instead of the username. There is a reasonable explanation for that.

An example command may look like this

ps aux | grep thisismyuser

May return something like

501 28373 15080 0 …

You may have expected a return like

thisismyuser 28373 15080 0 …

This behavior occurs because:

Why do long usernames get printed as numbers?

The UNIX and POSIX standards require that user names and group names be printed as decimal integers when there is not enough room in the column. Truncating the names, besides being a violation of the standard, would lead to confusion between names like MichelleRichards and MichelleRichardson. The UNIX and POSIX way to change column width is to rename the column:

ps -o pid,user=CumbersomeUserNames -o comm

The easy way is to directly specify the desired width:

ps -o pid,user:19,comm

A work-a-round that works is to use the following command.

ps -eo user:$(cut -d: -f1 /etc/passwd | wc -L),pid,ppid,c,stime,tname,time,cmd

The result and expected result.

thisismyuser 28373 15080 0 …

Source(s)
http://stackoverflow.com/questions/7440839/running-processes-why-displayed-uid-number-instead-username
http://procps.sourceforge.net/faq.html