How to Change the Short Name of a User Account in Mac OS X

May 20, 2011 - 21 Comments

Change a User Short Name in Mac OS X

In Mac OS X, a users short name is what their home folder is named after and it’s also the shorthand name for logging into the Mac either from a lock screen or a network connection with remote access through SSH and SFTP. There’s various reasons that you’d want to change the user short name, but it’s not just a matter of changing the name listed on a user account. We’ll cover four different ways to do this, a simple way that just changes the short user name for login purposes, and three more complete methods that will change not only the short user name but also the users directory name to match. Go with what is appropriate for your skill level.

It’s important to note here that spelling matters, as does capitalization, any differences in spelling or capitalization and things will not work. Do not attempt to use a short user name or account name that has spaces or special characters, keep it simple with normal characters.

Before proceeding, make sure you have a recent backup of your Mac and it’s important data. If you haven’t backed up in a while, you can force a manual backup in Time Machine easily. Once you’re backed up, read on.

Change the User Short Name Only

This is how you just change the actual short name of a user, for purposes of logging in to the Mac. This will not affect the name of the user account home directory:

  • Open System Preferences and click on the “Accounts” pane
  • Click on the lock icon in the lower left corner and enter your administrator credentials
  • Right-Click on the user whose short username you want to change and click on “Advanced Options”
  • Change a user short name in Mac OS X

  • From the “Advanced Options” screen, edit the user name as listed next to “Account name” as seen in the screenshot below

Change the user account short name in Mac OS X

Remember, the above instructions only change the users short account name and not the name of the users home directory. This brings us to a few different ways that we can change both the user account and the directory name:

Changing User Short Names & Home Directory Names: The Apple Way

This is the method that Apple recommends on their knowledge base, this method may seem lengthy but it automatically handles the permissions and file ownership changes, making it easier for some users.

  • First, you’ll need to enable the root user in Mac OS X if you haven’t done so already
  • Log out of your existing user account and log in to the enabled root user account
  • Open /Users/ and you will see the user account home directory, rename the user accounts home directory that you want to change the same way you would rename any folder or file in Mac OS X. Apple cautions that the user short name can not contain spaces or special characters
  • Now open System Preferences and click on the “Accounts” panel
  • Create a new user account with the same short name that you used to rename the users home directory
  • You will see a dialog warning “A folder in the Users folder already has the name “username you chose.” Would you like to use that folder as the Home folder for this user account?” – click OK
  • Now log out of the root user and log in to the newly created user with the short name you chose
  • Verify that all files, folders, permissions, ownership, and everything else is as expected. Navigate around, open a few files, etc. If things look good, you can now go back to the Accounts preference pane and delete the original user account

For security purposes, Apple recommends disabling the root user account, but you can determine whether or not that is necessary based on how often you need to use root access.

Advanced Approach: Changing the User Short Name & User Directory Name via Admin or root & chown

You can also use a more advanced approach which may be preferred by some, although for most users I would suggest Apple’s way. Proceeding along, if you wanted to change the users directory name as well as the short name, another way to do this is by using a separate Administrator account (or even root from the command line) to rename the users home directory (preferably to the new short name). You could do this from the Finder with an Admin account, or using sudo and root from the command line:

sudo mv /Users/oldname /Users/newshortname

Then, through the same process of accessing the “Advanced Options” of the Account panel as mentioned above, you will select the newly renamed home directory as the users default by clicking on the “Choose” button and then navigating to it. If you chose to do this through the command line, this is more of a confirmation step.

Change User Directory Name

After the directory name change has been made, you will likely need to adjust the file ownership and permissions using chown to the new username:

chown -R newshortname /Users/newshortname

As with the other methods, you’ll want to confirm that everything is working by logging into the newly renamed account and opening and accessing files.

On another note, you can also use this option to change the location of a users home directory. For example, if you have a small SSD drive for the operating system and applications to launch quickly off of but you want to keep all your files on a separate drive, but that’s branching onto a new topic.

Advanced: Changing Short User Names with sudo, mv, and Spotlight

Yet another method to change the short user name exists and it’s quite a bit more advanced.

Before beginning: Have a backup of your entire Mac done, this is editing user files and making changes to how the OS observes that user. If you don’t have a compelling reason to do this, or you aren’t comfortable with modifying system files and using the terminal, do not proceed. Also, you will probably want to enable Fast User Switching to be able to do this quickly. Done properly, you will have the short user name changed in just a few minutes, but this is not a traditionally supported method so proceed at your own risk!

This has been verified to work in OS X Mountain Lion. Always make a backup before modifying important files.

  • Log on to another Administrator account (create a new account with admin privileges if necessary)
  • Open Terminal from /Applications/Utilities/ and type the following commands:
  • sudo ls /Users/

  • Locate the old user name directory, make note of the exact spelling and capitalization, our example will use “OldShortName”, then use the next command replacing that username as necessary, and indicating the new short user name as desired
  • sudo mv /Users/OldShortName /Users/NewShortName

  • Enter the Admin password when requested, this is required for using sudo
  • Now pull down the  Apple menu and select System Preferences
  • Choose “Users & Groups” and select the user name you are changing
  • Right-click on the user name you wish to change and choose “Advanced Options…”
  • Change the fields next to “Account Name” and “Home directory” to accommodate the new short name
  • Click “OK” to accept the changes, there may be a slight delay as things are updated

The short user name is now changed, but you’re not quite done yet. Log out of the currently active Administrator account, or use Fast User Switching to summon the Login window and then log in as the newly renamed user.

This next set of steps is just as important, otherwise Spotlight and Smart Folders will not work:

  • Log in as the renamed user
  • Confirm the user files are where they are expected to be, in ~/Documents, ~/Desktop/ etc, open a few to verify that permissions are functioning as they should be
  • Now launch System Preferences from the  Apple menu and choose “Spotlight”, then click the “Privacy” tab
  • From the Finder, navigate to the /Home/ directory, select the newly renamed users directory, and drag and drop it into the Spotlight Privacy window
  • Now select the Users directory from the Spotlight Privacy window and delete it, this forcibly rebuilds the Spotlight index for this users files, allowing all files to be found as expected with Spotlight, Smart folders, and All My Files
  • Close out of System Preferences and wait for Spotlight to rebuild
  • When finished, open “All My Files” to see a list, and verify that Spotlight is now working by searching for a file with Command+Spacebar

If you did everything correctly, the users account short name will now be changed. If you wish to, you can now remove the extra administrator account

Updated: 1/25/2013

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Mac OS X, Tips & Tricks

21 Comments

» Comments RSS Feed

  1. Starbuck says:

    Bookmarked!

  2. Caffeine Junkie says:

    What if you just want to change your short name from all lower case to capitalized? i.e. from john to John

    • Will says:

      You’d have to go through the same process to make the exact change, but for such a minor thing it might be easier to just setup a username alias.

  3. Reb says:

    this one is really usefull!
    thanks!

  4. albinoz hack says:

    and what about :
    # ditto /Users/oldhome /Users/newhome ;)

    …ditto preserve all attributs
    Thanks 4 article

  5. [...] – April 17th, 2008 – 1 Comment Update – May 2011: We have written an up to date article on exactly how to change a short user name in Mac OS X. Please refer to that for further assistance, it will work on Snow Leopard and prior [...]

  6. [...] you don’t want to deal with the lengthy process of changing the short user name in Mac OS X, an alternative is to setup user name aliases. A user name alias functions as a simple way to [...]

  7. Ryan says:

    Someone please help. I think I just messed something up really bad. I entered this command into the terminal with my current name and preferred name: sudo mv /Users/oldname /Users/newshortname
    Then I logged out and back in. Now I’m left with what seems to be a fresh os (background, dock reset, and pictures, and documents missing. All that seems to remain are apps that I had downloaded that don’t come with the system. I am running lion by the way. Did I really delete all my stuff or can this be fixed?

  8. Jason Ban says:

    how do i got to users ?

  9. LP says:

    There’s a quicker way to do all this.

    Change user name to whatever you want.

    Change your Macs Name to desired short name.
    Via system preferences – sharing

    Enable root user.

    Log in as root user and change the name of the home folder to your short name.

    Log out root and back in as user, right click on user name and change home directory to the home folder you renamed, it’ll say you have to restart, click ok.

    Done

    This changes Everything you could possibly want to change regarding naming your Mac and home folder. I recently purchased a Mac mini with tiger from a friend and took these steps to rename everything. Funnily enough did it by accident but can vouch that I’ve done it and it works :)

  10. LP says:

    Sorry, also once it’s all done go to user and change your user to allow as an admin using root and the password you set earlier. Then turn root off to prevent security issues later.

  11. slugoo says:

    To modify (fix) permissions via chown -R, you’ll need a ‘sudo’ in front of the command…

  12. Cisco says:

    I LOVE YOU!!!! i just spent and hour looking how to change this, messing with everything in terminal, using all this non-sense….. all i wanted to change was the “CurrentDirectory User” THANK YOU!!!!

  13. Salmon says:

    I just did something really wrong. I typed in my new short name in home directory instead of account name. I rebooted and created a new account. Cant find and delete this account. Taking up masses of memory.

    Anyone help me please?

  14. Richard says:

    sluggo,

    %% needs to be in front of chown -R, (thats a CAPTIAL “R”).

  15. Richard says:

    I find it appalling, the lack of specificity amongst the Mac community. And the sudo command above really not necessary.

    be sure to reboot your system after you change your short name and long name before you do anything else. follow all on screen prompts before you use any terminal commands.

  16. Richard says:

    A fast fix for people to gain control over all their information again after seemingly losing it by misplacing your home directory;

    —-
    Apple’s support article HT1428: OS X: How to change user account name or home directory name, still refers to the old and buggy support article HT1528: Enabling and using the “root” user in Mac OS X. No one should ever need to enable the root user. This procedure is overly complex and buggy. If you really and truly need to act as the root user, use the Terminal and run the “sudo” command.

    Here is a better procedure for changing a user account short name that does not require the root user:

    Create a new Administrator account
    Log in as the new Administrator account
    Run Terminal.app and enter the following commands:
    cd /Users
    sudo mv oldshortname newshortname
    Where “oldshortname” is your old user name and “newshortname” is the user name you want to change it to. Keep in mind that both oldshortname and newshortname must be all lowercase, with no spaces, and only contain letters or numbers.
    The “sudo” command will prompt your for a password. Enter the password you used when creating the new Administrator account and press “enter”. Nothing will be echoed on the screen.
    Use the Users & Groups pane (Accounts pane in Mac OS X v10.6.8 or earlier) in System Preferences to create a new user with the Account name or Short Name that you used in the previous step.
    Click OK when “A folder in the Users folder already has the name ‘account name’. Would you like to use that folder as the Home folder for this user account?” appears. Note: This will correct the ownership of all files in the Home folder, and avoid permissions issues with the contents.
    Use the Users & Groups pane (Accounts pane in Mac OS X v10.6.8 or earlier) in System Preferences to delete the old user
    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).
    You will now need to rebuild the Spotlight index for your home directory. Follow the instructions in Spotlight: How to re-index folders or volumes and add your new home directory to the Privacy list and then remove it. This will trigger Spotlight to reindex your home directory and restore functionality of All My Files.
    After verifying that your data is as expected, you can delete the original user account via the Users & Groups pane (Accounts pane in Mac OS X v10.6.8 or earlier).


    https://discussions.apple.com/docs/DOC-3872

    & for reference,

    http://www.iclarified.com/entry/index.php?enid=4598

    As for the “root user” problem you will encounter in the iclarified article, you can always enable root commands in terminal by typing “sudo -i”. Although, if you follow the first one you’ll be home free.

    Now… Getting all that information and your UID back after you do that – Im still trying to figure that out right now, but I assume its essentially the same thing as the fix for this massive fuckup, albeit a modified terminal command with the correct chown -R command. Always use && before you type in commands like chown -R because && denominates the function thats typed after it to be run only if the first is successful.

  17. [...] in mind that the user name you’re looking to use is the account short name, which is usually what a home directory is named after. If you’re not sure what the short [...]

  18. R Montijo says:

    How do I update Java to the latest version?

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates