Jan 23

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

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.

Comments

1 ugg boots shoes says...

Ugg boots shoes <a href= http://www.uggsmall.com>Ugg boots shoes</a> five finger shoes <a href= http://www.acevibram.com/>five finger shoes</a> Uggs outlet <a href= http://www.uggsmall.com>Uggs outlet</a> cheap ugg boots <a href= http://www.uggsmall.com>cheap ugg boots</a> Ugg on sale <a href= http://www.uggsmall.com>Uggs on sale</a> Uggs australia <a href= http://www.uggsmall.com>Uggs australia</a> ugg bailey button boots <a href= http://www.uggsmall.com/ugg-bailey-button-boots-c-19.html... bailey button boots</a> ugg classic cardy boots <a href= http://www.uggsmall.com/ugg-classic-cardy-boots-c-2.html>ugg classic cardy boots</a> ugg nightfall boots <a href= http://www.uggsmall.com/ugg-nightfall-boots-c-4.html>ugg nightfall boots</a> ugg sundance ii boots <a href= http://www.uggsmall.com/ugg-sundance-ii-boots-c-5.html>ugg sundance ii boots</a> ugg classic mini boots <a href= http://www.uggsmall.com/ugg-classic-mini-boots-c-6.html>ugg classic mini boots</a> ugg kids boots <a href= http://www.uggsmall.com/ugg-kids-boots-c-20.html>ugg kids boots</a>

Posted at 3:44 a.m. on July 31, 2010

This won't be published anywhere, it's just in case I need to contact you.

You can use Markdown in your comments. Be sensible!

Sorry about this, but I don't want spam comments.