You are here: Home Blog Changing a user's home directory on Mac OS X Snow Leopard

Changing a user's home directory on Mac OS X Snow Leopard

by Dan Fairs last modified Jan 23, 2010 02:06 PM
After a botched PostgreSQL upgrade, I managed to leave my postgresql user with a non-existent home directory. Here's how to fix this on Snow Leopard.

I managed to mess up a PostgreSQL install on my Mac, which (somehow) left the postgres user account with an invalid home directory. Fixing this took quite a bit of digging.

First, launch the 'dscl' command as an administrator (probably with sudo). This drops you at a prompt, where familiar commands like cd, ls, cat and so on work. So, to change the user's home directory, I did:

 
bash $ sudo dscl
> cd /Local/Default/Users
/Local/Default/Users > ls
... user list ...
nobody
postgres
/Local/Default/Users > cat postgres
AppleMetaNodeLocation: /Local/Default
NFSHomeDirectory: /Users/dan/opt/pgsql
Password: *
PrimaryGroupID: 1
RealName: PostgreSQL
RecordName: postgres
RecordType: dsRecTypeStandard:Users
UniqueID: 504
UserShell: /bin/bash
/Local/Default/Users > change postgres NFSHomeDirectory /Users/dan/opt/pgsql /usr/local/pgsql
/Local/Default/Users > q
Goodbye
bash $

After that, the postgres user had a valid home directory, and all was well with the world.

Filed under: , ,
Arthur
Arthur says:
May 03, 2011 12:30 PM
Thanks!!
Adam
Adam says:
Oct 03, 2011 08:43 PM
Exactly what I was looking for, thanks very much!

Like the site design, too. The only thing would be the terminal's yellow highlighting makes it hard to read the text. I had to select the commands to see them properly - on FF on a Mac :)
Adam
Adam says:
Oct 03, 2011 08:58 PM
Ah, it's the search term highlighting. I see - refreshing the page makes it disappear. I found your page by googling "apple macosx postgres user account home directory" (3rd down) and it makes a bit of the terminal hard to read.

No need to approve this comment - it's more for you for information than for anything else. Thanks again!
Add comment

You can add a comment by filling out the form below. Plain text formatting.