The Two Ways to Change Your Linux Username

You can change your Linux username in two ways: rename your account while you are logged in as root or another administrator, or rename it while logged in as yourself using the usermod command. The first method is simpler and works on almost every Linux system. The second requires you to be in the sudoers group — a list of users allowed to run administrator commands.

Before you start, log out of the account you want to rename. You cannot change the username of an account you are currently using. If you are the only user on the system, restart your computer and log in as root instead, or boot into single-user mode. If another administrator account exists, log in as that user.

Your home directory — the folder where your files live — will keep its old name unless you rename it separately. Most people do this at the same time, so the instructions below cover both steps.

Key Takeaways

  • Log out of the account you want to rename before you start, because you cannot change the username of an account you are currently logged into.
  • The usermod command changes the username itself, and a separate step renames your home directory to match.
  • Your home directory keeps its old name by default, which can cause confusion later, so rename both at the same time.
  • After you rename an account, log in with the new username to confirm the change worked and your files are still accessible.

Renaming Your Account Using Usermod

Open a terminal and log in as root or another administrator account. Type the following command, replacing oldusername with the current username and newusername with what you want it to be:

usermod -l newusername oldusername

This changes the username in the system files. The command produces no output if it succeeds — that is normal. If you see an error saying the user does not exist, check that you typed the old username correctly and that you are logged in as root or an administrator.

Next, rename the home directory to match. Type this command, again replacing the old and new usernames:

mv /home/oldusername /home/newusername

This moves the entire folder from the old path to the new one. All your files stay inside and remain accessible. If the folder does not exist at that path — for example, if the home directory is in a different location — the command will fail. Ask your system administrator where home directories are stored on your system.

Updating the Group Name (Optional)

Linux also creates a group with the same name as your user account. Most of the time you do not need to change it, but if you want the group name to match your new username, type this command:

groupmod -n newgroupname oldgroupname

Replace oldgroupname and newgroupname with the old and new usernames. This step is optional and does not affect your ability to log in or access your files.

Fixing File Ownership After a Rename

When you rename the home directory, the files inside still belong to the old username in the system's records. To update all of them at once, use the chown command:

chown -R newusername:newusername /home/newusername

The -R flag means "recursive" — it changes ownership of the folder and everything inside it. The colon separates the user owner from the group owner. If you did not rename the group, use the old group name after the colon instead.

This step is important if you plan to use sudo or if other users on the system need to access your files. Without it, the system may prevent you from modifying your own files because they still belong to the old username.

Testing Your New Username

Log out of the administrator account and restart your computer, or switch to the login screen. Try logging in with your new username and the same password you used before. The password does not change — only the username does.

Once you are logged in, open a terminal and type whoami to confirm the system recognizes you by your new username. Type pwd to check that you are in the correct home directory. If both commands show the new username and the correct path, the rename was successful.

Open a file manager and navigate to your home directory to confirm your files are still there and you can open them. If you cannot read or modify files that you created before the rename, go back and run the chown command above.

What to Do If Something Goes Wrong

If you cannot log in after renaming, restart the computer and log in as root or another administrator account. Check that the username in the system files matches the home directory name by typing ls /home to see what directories exist. If they do not match, use the mv command to rename the directory again.

If you see a message that the user does not exist, the usermod command may have failed. Check the system files directly by typing cat /etc/passwd | grep newusername. If the new username appears in the output, the rename worked and the problem is elsewhere. If it does not appear, try the usermod command again and watch for error messages.

If you locked yourself out completely and cannot log in as any account, you may need to boot into single-user mode or use a live Linux USB to fix the problem. This is rare and usually only happens if you made a typo in the system files. Most renames work on the first try.

Renaming Multiple Accounts at Once

If you manage several user accounts on the same system, you can rename them one at a time using the same steps above. Write down the old and new usernames for each account before you start, so you do not mix them up. Rename one account completely — including the home directory and file ownership — before moving to the next one.

Do not rename the root account or any system accounts like bin, daemon, or nobody. These accounts are used by the operating system itself, and renaming them can break your system. Stick to user accounts that you or other people created.

Frequently Asked Questions

Does changing my username change my password?

No. Your password stays the same. You log in with your new username and your old password. If you want to change your password at the same time, log in with the new username and type passwd in a terminal.

What happens to my email or other programs that use my old username?

Programs that store your username in their settings will not automatically update. You may need to log out and log back in to email clients, chat applications, and other software. Some programs store the username in configuration files in your home directory — these usually update automatically when you rename the directory.

Can I rename my account without renaming the home directory?

Yes, but it creates confusion later. The username and home directory path will not match, which can cause problems with scripts and backups. It is simpler to rename both at the same time using the steps above.

What if I do not have root access or another administrator account?

You cannot rename your own account without administrator privileges. Ask your system administrator to rename it for you, or ask them to add you to the sudoers group so you can run the usermod command yourself.

Can I rename an account that is currently logged in?

No. The system will not let you change the username of an account that is in use. You must log out first, or log in as a different administrator account. If you are the only user, restart the computer and log in as root.