4

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 !

2 Answers 2

5

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
3
  • 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, 2011 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. Nov 2, 2011 at 14:20
  • Thanks Gordon. I think Apple should do something about su command as the user experience is very frustrating.
    – maksimov
    Jan 11, 2013 at 13:54
2

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.

1
  • 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, 2011 at 22:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .