I did a typo on all hundred of my Macs. Is there a command I can run to change the user account name from “old name” to “new name”?
These Macs haven’t been used yet.
If you still want to go all the way, here are the steps to follow; note that these instructions assume your home folder is located in /Users:
If Automatic Login is enabled (in Accounts preferences) for the account you’re modifying, disable it. Similarly, if File Vault is enabled (in Security preferences), disable it. You can re-enable these features, if desired, after completing the procedure.
Log in as a different user than the one you want to modify; make sure the account you want to modify is not logged in.
Open the Accounts pane of System Preferences.
If the lock icon in the lower-left of the Accounts window is “locked,” click on it and provide an administrative username and password; this allows you to make changes.
In the list of accounts on the left, right-click (or Control-click) on the name of the account you want to modify; choose Advanced Options from the resulting menu.
In the Advanced Options screen, delete your current short username in the Short Name field, and then type in your desired new short username.
In the Home Directory field, change /Users/oldusername to /Users/newusername, where oldusername is your original short username and newusername is your new short username. Make note of the original and new paths.
Click on OK and close System Preferences.
Open Terminal (in /Applications/Utilities).
Type the following command, all on one line, and then press Return; when prompted, provide the password of the admin account you’re currently using, and then press Return again:
sudo mv /Users/oldusername /Users/newusername
(These are the original and new Home Directory paths from Step 7; oldusername is your original short username and newusername is your new short username.) This step renames your home folder in the Finder.
Restart your Mac.
Changing the name of a home folder in Terminal
After the restart, your short username is completely changed, at least as far as Mac OS X is concerned—both your account name and the name of your home folder in the Finder have been updated.
One specific issue you may experience after performing this procedure is an inability to access Web Sharing for the modified accountinstead, you may see a “forbidden” or “403” error. (I tested the above procedure many times for this article and experienced this issue only once.) If this happens to you, follow the procedure in this Apple Support article; note that in Step 16 of the article, shortname means your new short username.
TIP: If after changing your account name, you find yourself occasionally typing your original username by accident, you can use the first procedure, above, to add your old name as an alias to your new one.
Advantages: Both your short username and your home folder in the Finder are changed; nearly-complete method of changing your short username.
Disadvantages: Can result in minor issues with services and applications that store their settings or data based on your short username or the path to your home folder; you may need to fix Web Sharing for it to recognize the change in your home directory.
You’ll notice that I called even the full-monty method a “nearly-complete” one. Primarly because of the potential issues I mentioned above with respect to settings, especially among third-party software. But also because I’m hedging a bit: In the past, Apple has stored a good number of user-level settings, and even a few system-level settings related to users, as references to users’ home directories; when working on ChangeShortName, my colleague James Bucanek and I regularly discovered, and had to account for, minor issues relating to such settings.
The good news is that many of the OS X settings that would break when you changed the short username in Tiger—even ones using home-directory paths—are automatically updated by the OS when you change the short username in Leopard. I’ve been pleasantly surprised by how well Leopard’s tools work.