The fastest way to change your Ubuntu username
You can change your Ubuntu username from the terminal using the usermod command, but only if you are not logged in as that user at the time. The safest approach is to log in as a different user (or use sudo from an account with administrator rights), then run a single command to rename the account you want to change. Ubuntu will update your username everywhere the system tracks it — in login records, file ownership, and group memberships.
If you are currently logged in as the user whose name you want to change, you have two options: switch to a different user first, or use a live USB to boot into Ubuntu without logging in to any account. The terminal method works the same either way.
Key Takeaways
- You cannot change your own username while logged in as that user; you must switch to a different account or use sudo from an administrator account.
- The command sudo usermod -l newusername oldusername changes the username itself, and sudo usermod -d /home/newusername -m oldusername moves your home folder to match.
- After changing the username, you may need to restart your computer or log out and back in for all changes to take effect.
- If you also want to change your display name (the full name shown in system menus), use sudo usermod -c "New Full Name" newusername after the username change.
Prerequisites: making sure you can run the command
To change a username in Ubuntu, you need to be logged in as a user with sudo privileges — usually the first user account created during installation. If you are trying to change your own username, you cannot do this while logged in as yourself.
The simplest workaround is to open a terminal and switch to another user account using su - otherusername, then enter that user's password. If no other user account exists on your system, you can enable the root account temporarily, or boot from a live USB and run the commands from there. For most people, creating a second temporary administrator account is the easiest path.
The two-step process to rename your account
Changing a username involves two separate commands. The first changes the username itself; the second moves your home folder so it matches your new name. If you skip the second step, your home folder will still be named after your old username, which can cause confusion later.
Open a terminal and run these commands in order, replacing oldusername with the current username and newusername with what you want it to be:
sudo usermod -l newusername oldusername
This renames the account. Then when ready run:
sudo usermod -d /home/newusername -m oldusername
The -d flag sets the new home directory path, and the -m flag tells Ubuntu to move all the files from the old folder to the new one. Without the second command, your files stay in /home/oldusername even though your account is now called newusername.
Changing your display name (full name) separately
Your Ubuntu username and your display name are two different things. The username is what you type at the login screen; the display name is what appears in system menus and settings. You can change one without changing the other.
If you want to update your display name to match your new username, run:
sudo usermod -c "Your New Full Name" newusername
Replace "Your New Full Name" with whatever you want to appear in system menus. This step is optional — many people leave their display name unchanged even after renaming their account.
What to do if you are locked out after the change
If you changed your username and now cannot log in, the most common cause is that the home folder move did not complete. You can check this by booting into recovery mode or from a live USB and looking at what folders exist in /home.
If the old folder still exists and the new one is empty, you can manually move the files by running sudo mv /home/oldusername/* /home/newusername/ from a live USB or recovery mode. If the new folder does not exist at all, create it first with sudo mkdir /home/newusername, then move the files.
After moving the files, you should also check that the ownership is correct by running sudo chown -R newusername:newusername /home/newusername. This ensures that your account actually owns the files in its home folder.
Verifying the change worked
After you run both commands, log out completely and log back in using your new username. Open a terminal and type whoami — it should print your new username. Then type pwd to see your current directory; it should show /home/newusername.
Check that your files are still there by typing ls in your home folder. If you see all your documents, downloads, and other folders, the change was successful. If the home folder appears empty, the move did not complete and you will need to use the recovery steps above.
When you might want to create a new account instead
Renaming an existing account works well if you are the only person using the computer and you straightforward want a different username. However, if you are trying to separate work and personal files, or if you want to keep your old account intact, creating a brand new account is often simpler than renaming.
You can create a new account from the terminal using sudo adduser newusername, then copy specific files from your old home folder to the new one. This approach takes longer but leaves your original account untouched, which is useful if something goes wrong or if you change your mind.
Frequently Asked Questions
Can I change my username without using the terminal?
Ubuntu's graphical settings do not offer a way to change your username. You can change your display name (full name) in Settings under Users, but the actual login username requires the terminal and the usermod command.
What happens to my files and folders when I change my username?
If you run both commands correctly, your files stay exactly where they are — they just move from /home/oldusername to /home/newusername. The ownership of the files is updated automatically so your new account can still access them.
Do I need to restart my computer after changing my username?
You do not need to restart, but you do need to log out completely and log back in. Some background services may not recognize the new username until you start a fresh login session.
What if I made a typo in the new username?
You can change it again by running the same two commands in reverse — use your current (misspelled) username as the old one and the correct spelling as the new one. The process is identical.
Will changing my username affect my sudo privileges?
No. Your sudo access is tied to your user account itself, not to the name. As long as your account was in the sudoers file before the change, it will still have sudo privileges afterward.