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 !

link|improve this question
feedback

2 Answers

up vote 3 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
link|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
feedback

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.

link|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
feedback

Your Answer

 
or
required, but never shown

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