Search code examples
macososx-mavericks

Change home directory in OS X Mavericks


After upgrading to OS X Mavericks, when I open terminal I get the following error.

No home directory: /home/(my-user-name)

I can navigate to /Users/(my-user-name) to access my files but I have to do it every time I open terminal. This also affects my projects which access home directory because the path is wrong.

Can anyone tell me how to change the home directory to /Users/(my-user-name)?


Solution

  • User records on OS X are stored in a "Open Directory" database. To modify the home directory for a user, you can either

    • open the "Directory Utility" app with

        open "/System/Library/CoreServices/Applications/Directory Utility.app"
        # On older macOS Versions:
        open "/System/Library/CoreServices/Directory Utility.app"
      
    • select the "Directory Editor" tab,

    • choose "Viewing: Users" in the pop-up,

    • select your user,

    • edit the "NFSHomeDirectory" entry,

    • save.

    Or, from the command line (as superuser):

    # dscl . -change Users/USERNAME NFSHomeDirectory OLDHOMEDIR NEWHOMEDIR
    

    In any case: be careful! A wrong edit in the user Open Directory database might make your system unusable.