How to add a new user that I can log in as with "su -l"

markpatterson

Registered
Hi,

I'm trying to get into PostgreSQL. I've installed it, following the instructions here: http://developer.apple.com/internet/opensource/postgres.html

Where I had to add a user I added it with NetInfo Manager, following the page that postgres site referred to: http://developer.apple.com/internet/opensource/osdb.html

But when I try to log in as postgres, I don't change user, so the next command fails with permission problems.

Code:
Pattersons-eMac:~ mark$ su -l postgres         
Password:
su: /dev/null: Permission denied
or
Code:
Pattersons-eMac:/usr/local/pgsql root# su -l postgres
su: /dev/null: Permission denied
or variations on that theme.
Does anyone recognise what this could be?

Regards,
Mark
 
su requires the password of the user you're going to su to, unless you're going from being root. Giving your postgres user a password, shell, and valid home directory would be a very bad idea, and unnecessarily being root is a slightly bad habit. sudo is definitely what you want.

Incidentally, you can also

sudo -s -u postgres

for the same effect, which will give you a shell, or

sudo -u postgres (whatever command)

which will just do the one command as postgres, and has the advantage, from a manageability point of view, that each command gets logged (to system.log or secure.log, I can't recall which). Then if something is messed up, you can check exactly who did what. Can be useful for debugging.
 
Viro said:
Try
Code:
sudo su -l postgres
Hey! That worked:
Code:
Pattersons-eMac:~ mark$ sudo su -l postgres
Password:
Pattersons-eMac:~ postgres$
Now, why didn't I think of that? I entered only my password.

Thanks
 
scruffy said:
su requires the password of the user you're going to su to, unless you're going from being root.
OK, that's useful to have cleared up

Giving your postgres user a password, shell, and valid home directory would be a very bad idea,
Yes, I agree, that's why I used NetInfo manager rather than System Preferences.

sudo -s -u postgres

for the same effect, which will give you a shell, or
I tried that and it worked as well as Viro's sudo su -l

Thanks
 
Back
Top