Mac OS X: Terminal Prompt Username

32,739

Be brave. This is not a big deal. I'll simplify the article from Apple Support, which is wordy and long and documents every button push.

Summary

  1. Rename the home folder.
  2. Update the Account with the new user and home folder names in System Preferences.

Details

Since you're changing system-level info, you need to have admin privileges. Create a new admin account and log in to it. Use a third name, different than the old and new names that you're changing. It's a good idea to have an extra separate admin account anyway.

  1. Rename the home folder.

    • In Terminal issue this command and type your admin password if/when prompted:

      sudo mv /Users/old_name /Users/new_name
      
    • You can verify success by listing the contents of the new folder and seeing your files there.

      ls /Users/new_name
      
  2. Update the OS X account to match the newly renamed home folder in the OS X Preferences.

    • Go to Preferences -> Accounts and click the lock icon to administer Accounts.

    • On the account you want to rename, control-click and choose advanced options.

    • Change the Account Name and Home Directory fields to the new desired values.

Share:
32,739
dfernan
Author by

dfernan

🇵🇹 DFIR, malware and Python!

Updated on September 18, 2022

Comments

  • dfernan
    dfernan over 1 year

    I'm using Mac OS Snow Leopard (v10.6.8). I've changed the account name under System Preferences > System > Accounts > Full Name. However, that does not change the username on the terminal prompt. That is, by changing the export PS1 to, for example, \u, the username remains the old one.

    I did not rename the home directory under /Users/username, but I was hoping it would be possible just to change that particular username on the terminal (I think it is called short name).

    • Admin
      Admin over 10 years
      Have you rebooted? What does running who or whoami return in a terminal?
    • Admin
      Admin over 10 years
      @terdon yes. The old username is outputted by those commands.
    • Admin
      Admin over 10 years
      Apple document on the subject: discussions.apple.com/docs/DOC-3872
    • Admin
      Admin over 10 years
      @Tim thanks. After reading that article the fear of changing the username from the main admin account popped in. I'm not confident in following that method. I guess Mac OS is just terrible in this regard.
    • Admin
      Admin over 10 years
      There's a user name for humans and a user name for machines. The name for machines usually consists only of lowercase ASCII letters, the name for humans can contain almost any printable character including spaces, diacritics, non-Latin letters, etc. You've changed the name for humans, but not the name for machines.