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.

I came from Linux world , and not familiar with OS X admin. Now I want to su to another user , but it just not working ... Where goes wrong here ?

smallufo@miniserver:~ $ whoami
smallufo
smallufo@miniserver:~ $ su - postgres
Password:
smallufo@miniserver:~ $ whoami
smallufo
smallufo@miniserver:~ $

I input correct password , but why I cannot su to postgres ?

Sorry if it is a dumb question , but I've been stuck with it the whole night...

Thanks a lot !

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

su should work normally in OS X. @Scott Warren's idea about the postgres user's shell is a possible explanation, but OS X doesn't use /etc/passwd except during bootup. Normal users (and groups etc) are stored in .plist files under /var/db/dslocal/nodes/Default/. The easy way to look at (and modify) them is with the dscl command:

dscl . -read /Users/postgres  # prints all user attributes
dscl . -read /Users/postgres UserShell # prints just the default shell

If necessary, you can set the shell the same way:

sudo dscl . -create /Users/postgres UserShell /bin/bash
share|improve this answer
    
Thanks a lot , it works ! ... though I don't understand the design consideration of Mac OS X ... I'll bookmark this question. –  smallufo Nov 2 '11 at 8:44
1  
OS X doesn't use /etc/passwd because its format is too limited -- a fixed number of fields per user, and no ability to have large amounts of data in the fields. Compare with a user record in OS X, where you'll often (but not always) find a JPEGPhoto attribute (with a hex-encoded image), an MCXSettings attribute (with an often-huge XML description of the user's managed preference/parental controls settings), etc. You just can't do that in an /etc/passwd entry. –  Gordon Davisson Nov 2 '11 at 14:20
    
Thanks Gordon. I think Apple should do something about su command as the user experience is very frustrating. –  maksimov Jan 11 '13 at 13:54
add comment

I don't have Postgres installed but check your /etc/passwd file. The last entry for that user account will be the shell that user uses. In my passwd file the accounts that shouldn't login (_lp,_postfix,etc.) have a shell of /usr/bin/false but accounts that can login are usually /bin/sh.

share|improve this answer
    
Hi , there is no 'postgres' user in /etc/passwd . But the user does exist. for example: I can see owner of '/usr/local/pgsql/data' is "postgres" . I don't know how Mac OSX (Snow Leopard) manage users. –  smallufo Nov 1 '11 at 22:22
add comment

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.