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@miniserver:~ $ su - postgres
smallufo@miniserver:~ $ whoami
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 !


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

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.

| 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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