The Two Ways to Change Your Ubuntu Username
You can change your Ubuntu username in two ways: by renaming your user account while logged in as a different administrator, or by using the command line. The first method works through Ubuntu's graphical settings and is safer if you are not comfortable with terminal commands. The second method is faster and gives you more control, but requires typing commands exactly as written.
Both methods do the same thing — they rename your user folder, your home directory path, and your system login name all at once. The key difference is that the graphical method walks you through each step, while the command line method does everything in one or two commands. Neither method is better; choose based on what you feel confident doing.
Before you start, log out of the account you want to rename. You cannot change the username of an account while you are logged into it. If you only have one user account on your machine, you will need to create a temporary administrator account first, log into that, and then rename your original account.
Key Takeaways
- You must log out of the account you want to rename before making any changes.
- The graphical method uses Ubuntu's Settings app and is the safest route if you are new to Linux.
- The command line method is faster but requires you to type commands exactly, with no typos.
- Changing your username also changes your home directory path from /home/oldname to /home/newname.
- If you make a mistake during the process, you can undo it by logging back in as an administrator and changing the name again.
Using the Graphical Settings Method
Open Ubuntu and log into a different administrator account — not the one you want to rename. If you only have one account, create a temporary one first by opening Settings, clicking Users, and selecting "Add User". Make sure you give it administrator rights by toggling the switch next to "Administrator".
Once you are logged into the administrator account, open Settings again. Click on Users in the left sidebar. You will see a list of all user accounts on your machine. Find the account you want to rename and click on it. You may need to click an "Unlock" button and enter your administrator password.
Look for a field that shows the current username — it may be labeled "Username" or "Account Name" depending on your Ubuntu version. Click on that field, clear the text, and type the new username. Ubuntu will show you what the new home directory path will be. Click "Change" or "explore" to save the change. Ubuntu will rename the account and its home folder in the background, which may take a minute or two.
Log out of the administrator account and log back into your renamed account using your new username. Your files, settings, and installed programs will all be exactly where they were — only the name has changed. If you created a temporary administrator account, you can delete it by going back to Settings, Users, clicking on the temporary account, and selecting "Delete User".
Using the Command Line Method
Open a terminal window while logged into an administrator account (not the account you want to rename). You can open a terminal by pressing Ctrl+Alt+T, or by clicking the Activities button in the top left, typing "terminal", and pressing Enter.
Type this command, replacing oldusername with your current username and newusername with what you want to change it to:
sudo usermod -l newusername oldusername
Press Enter and type your administrator password when prompted. This command changes your login name. Next, you need to rename your home directory folder to match. Type this command:
sudo mv /home/oldusername /home/newusername
Press Enter. This moves your entire home folder from the old path to the new one. You are done — log out and log back in using your new username. If you made a typo in either command, you can run them again with the correct spelling and it will fix itself.
What Changes and What Stays the Same
Your username changes everywhere Ubuntu uses it: your login screen, your terminal prompt, and your home directory path. Your home directory moves from /home/oldusername to /home/newusername. Any shortcuts or bookmarks that pointed to your old home directory will break and need to be updated manually.
Everything else stays exactly the same. Your files do not move or get deleted. Your installed programs continue to work. Your password does not change — you still log in with the same password, just with a different username. Your user ID number (a hidden number Ubuntu uses internally) stays the same, so file permissions and ownership do not break.
If you have set up SSH keys, cron jobs, or custom scripts that reference your old username, you will need to update those manually. For most people, a straightforward username change requires no follow-up work.
Fixing Problems If Something Goes Wrong
If you cannot log in after changing your username, log in as an administrator account and run the commands again with the correct spelling. If you do not have an administrator account to log into, restart your computer and hold Shift while it boots to enter recovery mode. Select "Drop to root shell prompt" and run the commands from there.
If you see a message that says the username is already in use, it means you typed a username that already exists on your machine. Choose a different new username and try again. If you see a message about the home directory not being found, run the second command (the mv command) again — it may not have completed the first time.
If your files seem to have disappeared after the change, they are still there but your file manager may be looking in the wrong place. Open a terminal and type pwd to see where you are, then type ls to list the files in that location. Your files are in /home/newusername, not the old path.
When to Create a Temporary Administrator Account
You need a second administrator account if you only have one user account on your machine and you want to use the graphical method. Creating a temporary account takes two minutes and you can delete it when ready after you finish renaming your main account.
To create a temporary account, log into your current account, open Settings, click Users, and select "Add User". Give it any name you want — something like "temp" works fine. Toggle the "Administrator" switch so it has admin rights. Set a password you will remember. Click "Add" and Ubuntu will create the account.
Log out of your main account and log into the temporary account. Now follow the graphical method steps above to rename your main account. When you are done, log out and log back into your renamed account to confirm it worked. Then log out again, log into the temporary account one more time, open Settings, Users, click on the temporary account, and select "Delete User". Choose "Delete Files" to remove it completely.
Frequently Asked Questions
Will changing my username affect my password?
No. Your password stays the same. You will log in with your new username but the same password you used before. If you want to change your password at the same time, you can do that separately through Settings or by typing passwd in a terminal.
Can I change my username back to what it was before?
Yes. Follow the same steps and change it back. You can rename your account as many times as you want. Each time you do, your home directory path changes to match.
What if I see a message saying the home directory already exists?
This usually means the second command (the mv command) did not complete. Log back into an administrator account and run the mv command again. If it still does not work, the new directory may already exist — type ls /home in a terminal to see what directories are there, and contact Ubuntu support with the output.
Do I need to reinstall my programs after changing my username?
No. Your installed programs stay installed and work exactly as before. They do not care what your username is — they only care that the files are in the right place, which they are.
Can I change my username without logging out first?
No. You must log out of the account you want to rename. If you try to change it while logged in, Ubuntu will not let you complete the change. Log out, switch to an administrator account, and then make the change.