2 Answers

up vote 2 down vote accepted

As you asked how to do it from the command line, I take you can open a SSH session for the Mac OS X server, or you can open a terminal window directly from the server.

If this is the case, then execute the following command: sudo dscl . -change /Users/<username> NFSHomeDirectory <old-path> <new-path>; replace <username>, old-path, and new-path with, respectively the user name, the old home directory, and the new home directory. The command -change requires the old value of the key being changed; if you don't know the old value, then you cannot do anything.

If you are no using any SSH session, or you cannot open a terminal window in the Mac OS X, but you can still access the server from another Mac, then the command is a little different. The dot after sudo dscl is the datasource, which is described as (dscl(1) Mac OS X Manual Page):

dscl operates on a datasource specified on the command line. This may be a node name or a Mac OS X Server (10.2 or later) host specified by DNS hostname or IP address. Node names may be absolute paths beginning with a slash ("/"), or relative domain paths beginning with a dot (".") character, which specifies the local domain, or "..", specifying the local domain's parent. If the hostname or IP address form is used then the user must specify the -u option and either the -P of -p options to specify an administrative user and password on the remote host to authenticate with to the remote host. The exception to this is if "localhost" is specified. Passing passwords on the command line is inherently insecure and can cause password exposure. For better security do not provide the password as part of the command and you will be securely prompted.

For more information, see the manual page installed in every Mac (man dscl), the online dscl(1) Mac OS X Manual Page.

link|improve this answer
If you have direct access to the server, then you can simply open the Accounts preference panel; selecting the user for which you need to change the home directory, and clicking with the right button, you will have access to the menu "Advanced options" that allow you to change the home directory, or select a new one. Take in consideration that, even using the preference panel, files are not moved from the old directory to the new one. – kiamlaluno Jun 21 '10 at 14:25
feedback

It can be done. Something like this:

Warning: Experiment with this on an unimportant account or machine first, I have not tested this.

sudo dscl . -change /Users/$USERNAME NFSHomeDirectory $OLDPATH $NEWPATH

...then of course to actually move their home directory folder to its new path, if you haven't done so already:

sudo mv $OLDPATH $NEWPATH

Note: dscl is the "Directory Services Command Line" utility. Also, don't worry that the key in question is called NFSHomeDirectory; that's a leftover from the heritage of the schema coming from LDAP.

By the way, for this kind of thing, the Mac OS X Server Administration Guides (freely downloadable PDFs) are your friends. Especially, in this case, the User Mangement one. It includes both the GUI and command-line ways to do many user management tasks. I believe the Open Directory Administration guide explains the schema.

I'm setting this as a community wiki so someone else can fix any syntax errors I may have committed.

link|improve this answer
Sorry @kiamlaluno, I had to roll back your edit, as all you did was remove useful information and break grammar rules. I had left it as a community wiki so people could fix my dscl command-line syntax, not make a mess of the text. – Spiff Jun 21 '10 at 6:08
You didn't precisate which syntax errors others should fix. About grammar rules, "Especially, in this case, the User Management one." is not a sentence, but a subordinate clause; you should have used a semicolon, instead of the full stop, in the previous sentence. Then, the warning message is a run-on sentence ("Experiment with this on an unimportant account or machine first, I have not tested this"). – kiamlaluno Jun 21 '10 at 12:56
@kiamlaluno "precisate" is not an English word. – trolle3000 Jun 21 '10 at 18:06
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.