30

I have Eucalyptus installed on my Linux machine, and I've noticed that for processes owned by the eucalyptus user, ps reports the userid instead of the username. For example:

$ sudo -i -u eucalyptus
$ ps u
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
107      29764  0.0  0.0  19376  2104 pts/2    S    11:43   0:00 -bash
107      30198  0.0  0.0  15256  1180 pts/2    R+   11:44   0:00 ps u

What would cause this to happen?

Note that there's a proper entry in /etc/passwd:

$ grep eucalyptus /etc/passwd
eucalyptus:x:107:115::/var/lib/eucalyptus:/bin/bash

Also note that ls property reports the ownership of files by the eucalyptus account:

$ touch foo
$ ls -l foo
-rw-r--r-- 1 eucalyptus eucalyptus 0 2010-09-23 11:47 foo

3 Answers 3

44

ps uses the uid when the username is longer than 8 characters.

2
  • Good call. From the man page: "This will be the textual user ID, if it can be obtained and the field width permits, or a decimal representation otherwise." Commented Sep 23, 2010 at 19:16
  • Or perhaps there is no way to translate UID to name.
    – vonbrand
    Commented Jan 23, 2013 at 15:52
14

You can control the width of columns:

ps o user:12,pid,%cpu,%mem,vsz,rss,tty,stat,start,time,comm

this reproduces the u format of ps u, but it makes the user field 12 characters wide.

0

Sure you have a problem with your /etc/passwd... you edited it manually, didn't you? :)

anyway, I reproduced the problem copying the line of the user in /etc/passwd and changing the user name by the user id.

Like this:

root@juice:/etc/# grep 129 /etc/passwd
129:x:129:137:Puppet configuration management daemon,,,:/var/lib/puppet:/bin/false
puppet:x:129:137:Puppet configuration management daemon,,,:/var/lib/puppet:/bin/false

Note that the "numbered user" is the first.

root@juice:/etc/# sudo -u puppet -s
129@juice:/etc/$ whoami
129

129@juice:/etc/$ touch /tmp/a
129@juice:/etc/$ ls -l /tmp/a
-rw-r--r-- 1 129 puppet 0 2010-09-23 19:12 /tmp/a

129@juice:/etc/$ ps u
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
129      12443  2.2  0.1   7112  4380 pts/1    S    19:12   0:00 /bin/bash
129      12490  0.0  0.0   2716  1068 pts/1    R+   19:12   0:00 ps u

Try to execute "whoami", sure it returns 107 :)

It is a strange behaviour, ps returns the number and ls the normal name :-m...

To solve it:

  • just edit /etc/passwd and delete the incorrect entry
  • or use 'userdel 107', but all programs from eucalyptus must be stoped

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .