Change your username from the command line using usermod

The fastest way to change your Ubuntu username is to use the usermod command in the terminal. This command modifies user account settings without requiring a restart. You will need to run it with administrator privileges, which means using sudo before the command.

Open a terminal and type: sudo usermod -l newusername oldusername. Replace "newusername" with what you want to be called and "oldusername" with your current username. The system will ask for your password to confirm you have permission to make this change.

This command changes only the login name itself. Your home directory — the folder where your files live — still has the old name. Most of the time this works fine, but some programs look for a home folder with a specific name and may not find it. If you want to rename the home directory too, you will need a second step.

Rename your home directory to match the new username

After changing your username with usermod, you can rename the home directory folder to keep things consistent. You will need to do this from a terminal while logged in as root or another administrator account, because you cannot rename a folder while you are actively using files inside it.

Type: sudo mv /home/oldusername /home/newusername. This moves (renames) the entire home directory from the old path to the new one. After this command runs, all your files, settings, and desktop preferences move with the folder.

If you skip this step, your username will be "newusername" but your files will still be in /home/oldusername. This usually causes no problems, but it can confuse you when you open a file manager and see a folder with a name that does not match your login.

Key Takeaways

  • Use sudo usermod -l newusername oldusername to change your login name in the terminal.
  • The usermod command changes only your username, not the home directory folder name.
  • Rename the home directory with sudo mv /home/oldusername /home/newusername to keep everything consistent.
  • You must have administrator access (sudo privileges) to run both commands.
  • Log out and back in after making these changes so Ubuntu loads your new username correctly.

Why you might need to change your username

Most people change their Ubuntu username because they set up the account with a temporary name, a nickname, or a name they no longer use. Others inherit a computer with an existing account and want to personalize it. Ubuntu lets you change this without losing any files or settings.

The username is different from the display name that appears on your desktop. If you only want to change how your name appears in menus and login screens, you can do that through Settings without touching the terminal. But if you want to change the actual login name you type at the password prompt, you need usermod.

What happens to your files and settings

Your files, desktop background, installed programs, and all your personal settings stay exactly where they are. The username change does not touch any of that data. Programs you have installed continue to work. Your email accounts, browser bookmarks, and document folders all remain accessible.

Some programs store settings in hidden folders inside your home directory using the old username as a reference. These programs almost always work fine with the new username because they look for the folder by location, not by name. If a program does have trouble, it is usually because it was looking for a home directory with a specific name — which is why renaming the home folder helps.

Changing your username without using the terminal

Ubuntu's graphical settings do not include an option to change your login username. The terminal method is the only way to do it. However, if you are uncomfortable using the command line, you can ask another administrator on the same computer to make the change for you — they can run the usermod command on your account.

Alternatively, you can create a new user account with the name you want, copy your files to it, and delete the old account. This takes longer but avoids the terminal entirely. You would go to Settings, then Users, create a new account, then manually move your documents and other files to the new account's home folder.

Troubleshooting common problems

If you get a "permission denied" error, you forgot the sudo at the start of the command. Type it again with sudo included. If you get "user is currently logged in" or "user is currently used by process", you are trying to change the username of the account you are currently using. Log out, log in as a different administrator account, then run the command on the account you want to change.

If you renamed the home directory but programs cannot find your files, check that you used the correct path. Type ls /home to see all the home directories on your computer and confirm the new folder name is there. If the folder has a different name than you expected, use mv again to rename it to match your new username.

Frequently Asked Questions

Do I need to restart Ubuntu after changing my username?

You do not need to restart the computer, but you should log out and log back in. This lets Ubuntu reload your user settings and environment with the new username. If you stay logged in, some programs may still refer to the old username until you restart them.

Can I change my username if I forgot my password?

No, you need to know your current password to run sudo commands. If you have forgotten it, you will need to boot into recovery mode or use another administrator account on the same computer. Ubuntu's password recovery process is complex and depends on your system setup.

What if I want to change my username back to the old one?

Run the same usermod command with the names reversed: sudo usermod -l oldusername newusername. If you renamed the home directory, rename it back too with sudo mv /home/newusername /home/oldusername. Everything returns to how it was.

Will changing my username affect my sudo access?

No. Your ability to use sudo is tied to your user account itself, not to the name you log in with. After you change your username, you can still run sudo commands the same way you did before.

Can I change my username to something that already exists on the computer?

No, Ubuntu will not let you create a duplicate username. If you try, usermod will return an error saying the username is already in use. Each username on a computer must be unique.