Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

10.5: Move a user's home directory via the command line System 10.5
Under Leopard, NetInfo is gone in all its forms. If you want to move a home directory (eg, to another volume) you may now use Directory Services which can be accessed with dscl (Directory Services Command Line).

The following is a summary version of this blog post; note that was written back in April, and the users listing is now in /Local/Default/Users not /Local/Users. Open Terminal (in /Applications » Utilities) and become root with sudo su -. Now fire up dscl by typing dscl localhost. Inside dscl, change directory to /Local » Default » Users:
cd /Local/Default/Users
You can list all users, if you want, by typing ls. For the user you wish to move, show all the Directory Services' attributes by typing cat someuser, where someuser is the short username of the user you wish to see. To change the user's home directory,

change someuser dsAttrTypeNative:home /Users/someuser /Volumes/path/to/new/home/someuser

Exit dscl by typing exit.

[robg adds: This is the no-GUI alternative to this hint, which is the easiest way to do the job.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[25,801 views]  

10.5: Move a user's home directory via the command line | 6 comments | Create New Account
Click here to return to the '10.5: Move a user's home directory via the command line' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
10.5: Move a user's home directory via the command line
Authored by: jctull on Tue, Oct 30 2007 at 7:37PM PDT
I found that blog post yesterday and put it to use trying to work out some postgresql issues. You can simply type 'dscl' without localhost to get things working. At least that worked for me.

[ Reply to This | # ]
10.5: Move a user's home directory via the command line
Authored by: wjv on Wed, Oct 31 2007 at 5:33AM PDT
You can start the command as "dscl ." (with a single dot) to connect to the relative (local) domain directly.

"sudo su -" is redundant, just use "sudo -s". But you don't even need to authenticate before starting dscl(1) in interactive mode: Just use the "auth" command once you're inside it.

In summary, non-interactively (from the command line):

sudo dscl . -change /Users/<username> NFSHomeDirectory <old_path> <new_path>

Note: None of this is guaranteed. My sole experience messing with it has been (as a previous user has noted) in trying to create a system account for PostgreSQL.

[ Reply to This | # ]
10.5: Move a user's home directory via the command line
Authored by: Interactive on Sun, Nov 4 2007 at 11:10AM PST
How would I go about moving the entire /Users folder to another volume? Please advise.

[ Reply to This | # ]
10.5: Move a user's home directory via the command line
Authored by: ddelo on Wed, Nov 7 2007 at 3:36PM PST
Since Leopard removes the NetInfo Manager utility, you can no longer use it to change your UID for the user account. Tiger also had command line utilities to modify the NetInfo database, but those have been removed as well.

In Leopard, you can use System Preferences or the dscl command line utility to modify the local user database.

To use dscl:

dscl . -read /Users/USERSHORTNAME

This will print out all the values for your user. Look for the UniqueID key and its value - this is what we are going to change.

To change the UID:
dscl . -change /Users/USERSHORTNAME UniqueID OLDUID NEWUID

Leopard's System Preferences also has a much easier to do this. Open the Accounts System Preferences and click the lock and authenticate. Then, for the user you want to change, RIGHT-click on the "Admin" or "User" text below the user's name. A contextual menu "Advanced Options" should appear - click on that. A sheet will appear with information about your user. You can change the UID from this pane. You can also change your shell, group ID and other user information from here.

Once you have done this, your files will still be associated with the old UID.

Run:
sudo find -x / -user OLDUID -exec chown NEWUID {} ;

to get your files back.

[ Reply to This | # ]
10.5: Move a user's home directory via the command line
Authored by: dgm on Wed, Sep 17 2008 at 5:14PM PDT
Does 10.5.5 break this hint? i've been using this hint since Leopard came out without problems. after installing the 10.5.5 patch though my moved home directory was not used. instead the default of /Users was used. i've tried to reset the moved home directory in dscl as described above but now get an error that the dsAttrTypeNative cannot be found. a cat of my user info does not show the information although the NFShomedirectory is set to the proper directory.

i've googled the problem but have found nothing apropos. i've checked the apple support site and found nothing there.

i did check the dscl and the DirectoryServiceAtrributes man pages. i did not see the attribute listed or mentioned. i did see dsAttrTypeStandard:HomeDirectory and tried it but again the attribute not found error.

help please. i've been unable to get to my home account normally for the last day.

thanks



[ Reply to This | # ]
10.5: Move a user's home directory via the command line
Authored by: 25ghosts on Thu, Sep 18 2008 at 3:30AM PDT
Hi There,

I am on 10.5.5 and my moved home dir works just fine. Only I did not do it over the terminal command line.

Just go to System Preferences and select accounts. Now click to the "lock" and enter your password.

Now right mouse click the admin account and chose "Advanced" in there you may point to any directory you like

IHTH

[ Reply to This | # ]