Changing Your Username and Password: The Two Separate Processes
Your Linux username and password are two different things, and you change them in different ways. Your password you can change yourself from the command line in about thirty seconds. Your username — the name you log in with — requires either administrator access or help from someone who has it, because Linux does not let you rename your own account while you are logged into it.
This guide covers both. Start with whichever one you need first. If you are locked out or cannot remember your current password, skip to the password recovery section near the end.
Key Takeaways
- Change your password yourself by opening a terminal and typing passwd, then entering your current password and your new one twice.
- Changing your username requires administrator (sudo) access and involves the usermod command, which you cannot use on your own account while logged in.
- When you change your username, your home directory path does not change automatically — you must rename it separately or create a new one.
- If you forget your password, you will need to boot into recovery mode or ask an administrator to reset it for you.
- Test your new password or username when ready after making the change, before you close the terminal or log out.
Changing Your Password from the Terminal
Open a terminal window. You can usually do this by right-clicking on the desktop, pressing Ctrl+Alt+T, or searching for "Terminal" in your applications menu. Once it opens, type this command and press Enter:
passwd
Linux will ask you to enter your current password. Type it in — you will not see the letters appear on screen, which is normal — and press Enter. Then type your new password and press Enter. Linux will ask you to type the new password again to confirm you did not make a typo. Type it once more and press Enter.
If the passwords match and meet your system's requirements (usually at least 8 characters, though this varies), the change takes effect when ready. You do not need to restart or log out. The next time you log in, use your new password.
Changing Your Username with Administrator Access
Changing your username is more involved because you cannot rename an account while you are logged into it. You have two options: log in as a different user who has administrator access, or ask an administrator to make the change for you.
If you have administrator access on another account on the same computer, log into that account. Open a terminal and use the usermod command. Replace oldusername with the username you want to change and newusername with what you want it to be:
sudo usermod -l newusername oldusername
Press Enter. Linux will ask for the administrator password (the password of the account you are currently logged into). Type it and press Enter. The username changes when ready.
Renaming Your Home Directory After a Username Change
When you change your username, your home directory — the folder where your files, settings, and desktop configuration live — keeps its old name. This does not break anything, but it is cleaner to rename it to match. You must do this as an administrator.
While logged into an administrator account, open a terminal and type:
sudo mv /home/oldusername /home/newusername
Replace oldusername and newusername with the actual names. Press Enter and type the administrator password when prompted. The directory is renamed when ready.
After this, log out of the administrator account and log back in with your new username and your original password. Your files, desktop settings, and applications should all be exactly where you left them.
What Happens If You Forget Your Password
If you cannot remember your password and no administrator account is available, you will need to boot your computer into recovery mode. The exact steps depend on whether you use GRUB (the most common boot menu on Linux systems) or a different bootloader, and they vary between Linux distributions.
The general process is: restart your computer, hold down Shift while it boots to open the GRUB menu, select "recovery mode" or "single-user mode", and follow the prompts to reset your password. Some systems will drop you to a root shell where you can type passwd username to set a new password for that user.
If you are not comfortable with this process, contact your system administrator or the person who set up your computer. They can reset your password without losing your files.
Changing Another User's Password as an Administrator
If you have administrator access and need to reset someone else's password, open a terminal and type:
sudo passwd username
Replace username with the account you want to change. Press Enter, type your administrator password, and then type the new password twice. You do not need to know the old password. The change takes effect when ready, and the user can log in with the new password on their next login.
Testing Your Changes Before You Log Out
After you change your password or username, do not close the terminal right away. Open a second terminal window or tab and try to log in with your new credentials. This catches typos or mistakes before you lock yourself out.
If you changed your username, try logging into a different virtual desktop (usually Ctrl+Alt+F2 on most Linux systems) and log in with the new username and your original password. If it works, you are done. If it fails, switch back to your original terminal and troubleshoot before closing anything.
Frequently Asked Questions
Can I change my username without administrator access?
No. Linux prevents you from renaming your own account while you are logged in. You need either an administrator account on the same computer or someone with administrator access to make the change for you.
Will changing my username delete my files?
No. Your files stay in your home directory. If you do not rename the directory itself, your files will be in a folder with your old username, but they are still there and still yours. Renaming the directory is optional and does not affect your files.
What if I change my password and then forget the new one?
You will need to boot into recovery mode or ask an administrator to reset it. There is no way to recover a forgotten password on your own without administrator access.
Do I need to restart my computer after changing my password?
No. Password changes take effect when ready. You can keep working without restarting. The new password is required the next time you log in.
Can I change my username and password at the same time?
You can change your password yourself anytime. To change your username, you need administrator access. If you have it, you can do both in the same session — change the username first, then log in with the new username and change the password if you want to.