When I first got my Mac, I wasn’t a keen user of the Terminal, so the user short name isn’t something that I would care, therefore it was all set up using the auto generated stuff when I first started my new Mac. Ever since I started working, stuff like bash and unix started popping up, and I started using the terminal and ssh became a daily routine. With the short and easy username I chose for all my unix needs, doing ssh from my mac became troublesome, because the auto generated short name is different, therefore I had to specify the username every time I had to login to somewhere.
To change the short name itself is relatively easy, and there’s even a guide in Apple’s knowledge base. The problem, however, is the trouble you’ll soon encounter after changing the short name, which is the reason I’m writing this post today. Before you start doing any modifications, I’d strongly suggest that you do a full backup of your Mac with Time Machine (or any other backup software of your choice). Lastly, follow this guide at your own risk. Although these are the exact steps I’ve taken and have not encountered any problems so far, I will not go as far as to guarantee your Mac’s safety.
Important: I strongly suggest that you backup your entire computer with Time Machine (or your favourite backup software) before proceeding.
Changing the short name (Steps from Apple’s knowledge base):
-
Enable root user:
There are 2 ways to do this.- Follow this guide from Apple.
-
Or you could type this into your Terminal:
username$ sudo passwd rootEnter your user’s password if prompted and give your root account an extremely secure password.
-
Using Terminal, login as root:
username$ su -
Navigate to the /Users folder:
username$ cd /Users -
Select the Home folder with the short name you want to change, and rename it just like you would rename any folder. Keep in mind that the shortname must be all lowercase, with no spaces, and only contain letters (Replace “username” with your current short name and “newname” with the new short name):
username$ mv username newname - Use the Accounts pane in System Preferences to create a new user with the short name that you used in the previous step.
- Click OK when “A folder in the Users folder already has the name ‘short name’. Would you like to use that folder as the Home folder for this user account?” Note: This will correct the ownership of all files in the Home folder, and avoid permissions issues with the contents.
- Choose Log Out from the Apple menu.
- Log in as the newly created user. You should be able to access all of your original files (on the desktop, in Documents, and in the other folders of this Home).
Now that you’ve changed your user short name, everything seems fine. What you currently don’t see, is that all the files that’re not in your Home directory still belong to the previous user account. To change the owner of these files, follow the steps below.
Changing file owner:
- Using the Accounts pane in System Preferences, right click on the old user and select Advanced Options. Take out a piece of paper and write down the number in the field User ID. You will need this later.
-
Open Terminal and navigate to the upper most level directory:
newuser$ cd / -
Run the following in Terminal (Replacing “501″ in the command below with the user id you wrote down earlier and “newuser” with your new short name):
newuser$ sudo find / -user 501 -exec sudo chown -h newuser {} \;The command above searches all files (starting from the highest level directory) for files that are owned by the given user id (in this example: 501) and changes the owner to the given new user (in this example: newuser). Note: This step takes quite a while, depending on the amount of files you have.
- After verifying that your data is as expected, you can delete the original user account via the Accounts pane of System Preferences.
- Finally, disable root user.
Update: If you use Time Machine, it is recommended that you follow this guide to fix it. I have not tested it myself for I currently have no access to a Leopard installation disc. Will post an update on the status after I’m done with it.
Update 2: If you are using Snow Leopard, chances are you will not have ‘fsaclctl’ on your Mac. In order to obtain this, you will need a Leopard Installation DVD, and follow this guide to extract it from the DVD.
Update 3: I’ve tried and tested the method I posted above to fix Time Machine. It seems to be working just fine for me.






























