0

Since upgrading my debian lenny box with apt-get, ps seems to be behaving strangely, and also if i run top i see under the user column the ids, not the names.

whoami => foo
ps -U foo => ERROR: User name does not exist.

I get this output when I run "strace -e trace=open ps -U foo 2>&1 | less", seems just this /usr/lib/libnss_compat.so.2 doesnt exist:

open("/etc/mtab", O_RDONLY)             = 3
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
open("/proc/self/stat", O_RDONLY)       = 3
open("/proc/uptime", O_RDONLY)          = 3
open("/etc/nsswitch.conf", O_RDONLY)    = 4
open("/etc/ld.so.cache", O_RDONLY)      = 4
open("/lib/libnss_compat.so.2", O_RDONLY)=4
open("/usr/lib/libnss_compat.so.2", O_RDONLY)=-1 ENOENT (No such file or directory)
open("/proc/self/stat", O_RDONLY)= 4                                       
200_success
  • 4,771
  • 1
  • 25
  • 42

1 Answers1

0

Having the wrong permissions on /etc/nsswitch.conf can cause this:-

[asmith@therapy ~]$ ls -la /etc/nsswitch.conf
-rw-r--r-- 1 root root 525 2010-03-31 18:35 /etc/nsswitch.conf

[asmith@therapy ~]$ ps -ef
...
asmith   31143 31124  0 Jan13 pts/18   00:00:00 /bin/bash
asmith   31156 31124  0 Jan13 pts/19   00:00:00 /bin/bash
...

[asmith@therapy ~]$ sudo chmod 600 /etc/nsswitch.conf
[asmith@therapy ~]$ ps -ef
...
1794114690 31143 31124  0 Jan13 pts/18 00:00:00 /bin/bash
1794114690 31156 31124  0 Jan13 pts/19 00:00:00 /bin/bash
...

[asmith@therapy ~]$ ps -U asmith
ERROR: User name does not exist.

[asmith@therapy ~]$ sudo chmod 644 /etc/nsswitch.conf
[asmith@therapy ~]$ ls -la /etc/nsswitch.conf
-rw-r--r-- 1 root root 525 2010-03-31 18:35 /etc/nsswitch.conf

[asmith@therapy ~]$ ps -U asmith
31143 pts/18   00:00:00 bash
31156 pts/19   00:00:00 bash

Hope that helps!

Andy Smith
  • 1,828
  • 14
  • 15
  • Thanks for the try, that doesn't seem to be the cause though... perhaps some other permissions are messed up? – William Coates Jan 15 '11 at 13:27
  • Could be - it could also be incorrect settings within `/etc/nsswitch.conf`. My next step would be to run `strace -e trace=open ps -U foo 2>&1 | less`, and have a look towards the beginning of the output to see if `ps` is having problems accessing anything. – Andy Smith Jan 15 '11 at 19:53
  • Everything seems to exist except /usr/lib/libnss_compat.so.2, see above (not enough chars in a comment :/) – William Coates Jan 16 '11 at 04:51