Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,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 2.88 / 5
  You rated: 5 / 5 (8 votes cast)
 
[51,946 views]  

10.5: Move a user's home directory via the command line | 7 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 whoever 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 Oct 30, '07 07:37:56PM

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 Oct 31, '07 05:33:28AM

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 Nov 04, '07 11:10:48AM
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 Nov 07, '07 03:36:30PM

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 Sep 17, '08 05:14:59PM

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 | # ]
FIND command clarification
Authored by: Alper on Mar 17, '10 07:41:54AM
Thanks so much for this System Preference heads up. Exactly what I needed for a distinctly different problem. Two things that users should be aware of: 1. In certain situations the ";" portion of the find command needs to be "escaped" in order for it to be visible to the command. You'll recognize the situation because find will complain that there's "no terminating ';' or '+'." I'm this case you need to enclose the ";" in single quotes, as in:
sudo find -x / -user OLDUID -exec chown NEWUID {} ';'
2. Depending on the number of files associated with the old UID, this command can take a very long time (way longer than a permissions repair, for example).

[ Reply to This | # ]
10.5: Move a user's home directory via the command line
Authored by: 25ghosts on Sep 18, '08 03:30:36AM

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 | # ]