The fastest way to change your Ubuntu username
You can change your Ubuntu username in two ways: rename your user account while logged in as root or another admin user, or create a new account and transfer your files. The logged-in method is faster but requires you to log out first and use a different account temporarily. Both methods preserve your files and settings.
The command-line approach takes about five minutes and works on any Ubuntu version. You will need to know your current username and have admin (sudo) access. If you are the only user on the machine, you will need to enable the root account or create a temporary second admin account first.
The reason you cannot rename your own account while logged in is that Ubuntu locks user accounts during active sessions. Attempting to modify an account that is currently in use can corrupt file permissions or leave the system in an inconsistent state. This is a safety feature, not a limitation of the tool.
Key Takeaways
- You cannot rename your own user account while logged in as that user — you must log out and use a different admin account.
- The usermod command renames the account, but you also need to rename your home directory folder to match.
- If you are the only admin user, create a temporary second admin account before starting the rename process.
- After renaming, log back in with your new username and delete any temporary accounts you created.
- Your files, permissions, and settings stay intact when you rename — only the account name changes.
Prepare by creating a temporary admin account if needed
If you are the only user on your machine, you cannot rename your own account while logged in. You need a second admin account to do the renaming. Open a terminal and run this command to create a temporary account called tempuser:
sudo adduser tempuser
The system will ask for a password for tempuser. Write it down. Then add tempuser to the sudo group so it has admin rights:
sudo usermod -aG sudo tempuser
Log out of your current account. At the login screen, select tempuser and log in with the password you just created. You are now ready to rename your original account.
Rename the user account with usermod
Open a terminal in your tempuser session. Replace oldusername with your actual current username and newusername with what you want it to be:
sudo usermod -l newusername oldusername
This command changes the account name in Ubuntu's user database. The system will not ask for confirmation — the change happens when ready. If you see no output, the command worked. The -l flag stands for "login" and tells usermod to change the login name specifically.
Now you need to rename your home directory folder to match. The folder is usually located at /home/oldusername. Run this command:
sudo mv /home/oldusername /home/newusername
Again, no output means success. Your account name and home folder now match. This step is critical because Ubuntu expects the home directory name to correspond to the username.
Update your home directory setting
Ubuntu stores which folder belongs to your user account in a system file. After renaming the folder, you need to update that setting. Run this command, replacing newusername with your new account name:
sudo usermod -d /home/newusername newusername
This tells Ubuntu that the user newusername lives in /home/newusername. Without this step, your account may not find its files correctly when you log in, and some programs may not locate your configuration files.
You can verify the change worked by opening a terminal and running echo $HOME. It should display /home/newusername.
Log in with your new username and clean up
Log out of tempuser. At the login screen, you should now see your new username listed. Log in with your new username and your original password — the password does not change, only the account name does.
Once you are logged in and can see all your files and settings intact, you can delete the temporary account. Open a terminal and run:
sudo deluser tempuser
If you want to also remove tempuser's home folder and all its contents, add this command:
sudo rm -rf /home/tempuser
Your rename is complete. Your new username is now the only admin account on the machine.
What to do if something goes wrong
If you cannot log in after renaming, log back in as tempuser and undo the changes. Run the usermod command again with the names reversed:
sudo usermod -l oldusername newusername
Then rename the home folder back:
sudo mv /home/newusername /home/oldusername
And update the home directory setting again:
sudo usermod -d /home/oldusername oldusername
After that, log out and try logging in with your original username. If you still have trouble, restart your machine and try again — sometimes the system needs to refresh its user cache before recognizing the restored account.
Frequently Asked Questions
Will changing my username affect my installed programs?
No. Programs are installed system-wide and do not depend on your username. They will work exactly as before. Some programs store settings in your home folder, and those settings will move with your renamed home directory automatically.
What if I forget the password I set for tempuser?
You cannot log in as tempuser without the password. Restart your machine and log in as your original account instead. You will need to create a different temporary account with a password you can remember, or ask another admin user on the machine to do the rename for you.
Can I rename my username without using the terminal?
Ubuntu's graphical settings do not offer a rename function. You can change your display name (the name that appears on the login screen) through Settings > Users, but this does not change your actual username. The terminal method is the only way to change the username itself.
Do I need to change my password after renaming?
No. Your password stays the same. If you want to change it, you can do so after logging in with your new username by running passwd in a terminal.