Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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                                       
share|improve this question
    
Do you use nis, ldap or somesuch as your userdatabase ? –  Kjetil Joergensen Jan 14 '11 at 13:36
1  
Does getent passwd foo work? –  Dennis Williamson Jan 14 '11 at 13:39
    
getent passwd foo does work –  William Coates Jan 15 '11 at 13:25
    
Not using nis, ldap or anything funky –  William Coates Jan 15 '11 at 13:26

1 Answer 1

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!

share|improve this answer
    
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 4:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.