The fastest way: use usermod from the command line
The quickest route is to open a terminal and run a single command as root. Log in as a user with sudo privileges, then type sudo usermod -l newusername oldusername, replacing newusername and oldusername with the actual names. Ubuntu will change your login name when ready, but your home folder will still have the old name — you will need a second command to fix that.
After the usermod command completes, rename your home directory with sudo mv /home/oldusername /home/newusername. Then update the home directory path in the system files by running sudo usermod -d /home/newusername -m newusername. The -m flag tells usermod to move the contents of the old home folder to the new location automatically.
You must be logged in as a different user to run these commands — you cannot change the username of the account you are currently using. If you only have one user account, create a temporary admin account first, log into that, then run the commands above for your main account.
Key Takeaways
- Change your login name with sudo usermod -l newname oldname, then move your home folder with sudo mv /home/oldname /home/newname.
- You cannot change the username of the account you are logged into — you must switch to a different user account first.
- If you only have one account, create a temporary admin user, log into it, then change your main account's name.
- After changing your username, log out completely and log back in to confirm the change took effect.
- The graphical Settings app cannot change your login username — only the command line method works.
Creating a temporary admin account if you need one
Open a terminal and run sudo adduser tempuser. Ubuntu will prompt you for a password and some optional details — you can skip the optional fields by pressing Enter. When prompted to confirm, type Y and press Enter. The new account is created when ready.
Give this temporary account sudo privileges by running sudo usermod -aG sudo tempuser. Then log out of your current session by clicking your username in the top-right corner and selecting Log Out. At the login screen, click your username and select tempuser from the list, or type tempuser manually. Enter the password you created.
Once you are logged in as tempuser, open a terminal and run the usermod and mv commands from the section above to change your main account's username. After the change is complete, log out and log back into your renamed account to verify it worked. You can then delete the temporary account by running sudo deluser --remove-home tempuser from your main account.
What happens to your files and folders
Your personal files, documents, and settings live in your home directory, which is usually /home/yourname. When you change your username without moving the home folder, your files stay in the old folder path and you may lose access to them or see permission errors. Running the mv command ensures your files move to the new home directory path and remain accessible.
Some applications store settings in hidden folders inside your home directory — these are folders whose names start with a dot, like .config or .local. The mv command moves these automatically, so your process settings, browser history, and saved preferences stay intact. You do not need to manually copy or restore anything.
Fixing permissions if something goes wrong
If you see permission denied errors after changing your username, your home folder may still be owned by the old username. Open a terminal and run sudo chown -R newusername:newusername /home/newusername to transfer ownership of all files in your home directory to your new username. The -R flag means recursive, so it fixes permissions on every file and subfolder.
If you renamed your home folder but forgot to update the system path, you can fix it by running sudo usermod -d /home/newusername newusername. This tells the system where your home directory actually is. After running this command, log out and log back in to confirm the path is correct.
Why the graphical settings app does not work
Ubuntu's Settings process has a Users panel, but it only lets you change your display name — the friendly name that appears in the login screen and system menus. Your actual login username, which is what you type at the login prompt and what appears in the terminal, cannot be changed through the graphical interface. This is by design: changing a login username requires modifying system files and moving directories, which the Settings app does not do.
The display name and login username are separate things. You can have a login username of jsmith but a display name of John Smith. If you only want to change how your name appears on the login screen and in menus, the Settings app is sufficient. If you want to change the actual username you type to log in, you must use the command line.
Changing your username on a system you do not administer
If you are on a work or school network where a system administrator manages user accounts, you cannot change your own username using the method above. Contact your IT department or help desk and request a username change. They have tools to change usernames across the entire network and update your account on file servers and email systems at the same time.
Attempting to change your username on a managed system without permission can cause problems with network access, file sharing, and email. Your administrator needs to coordinate the change across multiple systems to keep everything working.
Frequently Asked Questions
Will changing my username log me out when ready?
No. The change takes effect the next time you log in. You can stay logged in under your old username for as long as you want, but once you log out, you must use your new username at the login screen. Log out completely and log back in to start using the new username.
What if I forget my new username after changing it?
You can see all usernames on your system by opening a terminal and typing cat /etc/passwd. Look for your entry — it will show your username, user ID, home directory path, and shell. If you are locked out of the login screen, boot into recovery mode by holding Shift during startup and selecting recovery from the menu.
Can I change my username back to the old one?
Yes, use the same usermod and mv commands with the new and old names swapped. For example, if you changed from john to jane, run sudo usermod -l john jane and sudo mv /home/jane /home/john. You must be logged in as a different user to do this.
Do I need to change my password when I change my username?
No. Your password stays the same — it is tied to your user account, not your username. You can log in with your new username and the same password you used before. If you want to change your password at the same time, run passwd in a terminal after logging in with your new username.
What if the usermod command says the user is currently logged in?
You are trying to change the username of the account you are currently using. Log out completely, log in as a different user (or create a temporary admin account), then run the usermod command. You cannot modify an account while it is active.