The usermod command is the standard way to rename your account

To change your username in Debian, you use the usermod command from the terminal. This tool modifies user account settings without deleting your files or permissions. The basic command is usermod -l newusername oldusername, where you replace newusername with what you want and oldusername with your current name.

You cannot change the username you are currently logged in as — you must run the command as root or through a user with sudo privileges. The safest approach is to log in as a different user first, or use sudo from your current account. If you are the only user on the system, you will need to boot into single-user mode or use a live USB to make the change.

Changing the username does not touch your home directory, your files, or your group memberships. It only changes the name that appears in the terminal prompt and in system logs. If you want to rename the home directory itself (from /home/oldusername to /home/newusername), that is a separate step done after the usermod command.

Key Takeaways

  • Use usermod -l newusername oldusername to change the username itself, but you must not be logged in as that user when you run it.
  • If you are the only user, log in as root first or boot into single-user mode, because you cannot change your own active username.
  • The usermod command changes only the username — your files, permissions, and home directory path stay the same unless you rename the directory separately.
  • Renaming the home directory requires a second command: mv /home/oldusername /home/newusername, run as root after the usermod step.
  • Update your home directory path in the passwd file if you rename the directory, using usermod -d /home/newusername username.

Step-by-step: changing the username when you have another user account

If your system has more than one user account, the easiest path is to log out of your account and log in as a different user. Open a terminal and type whoami to confirm you are not logged in as the account you want to rename. Then run the usermod command:

sudo usermod -l newusername oldusername

Replace newusername with the name you want and oldusername with your current username. If you are not in the sudo group, you will see a "not in the sudoers file" error — in that case, you need to log in as root instead. Type su - and enter the root password, then run the usermod command without sudo.

After the command completes with no error message, the username is changed. Log out and log back in with your new username to confirm. Your password, files, and permissions remain exactly as they were.

Changing the username when you are the only user

If you are the only user on the system, you cannot run usermod while logged in as yourself. You have two options: boot into single-user mode, or use a live USB.

Single-user mode: Restart your computer and hold Shift during boot to open the GRUB menu. Select the entry that says "recovery mode" or "single-user mode". The system will boot to a root prompt without loading the graphical desktop. Type the usermod command as shown above, then type exit to finish booting normally.

Live USB: Boot from a Debian live USB (the same one you used to install, or a newer version). Once the live desktop loads, open a terminal and run sudo usermod -l newusername oldusername. The live system has root access and the target user is not logged in. Reboot into your installed system when done.

Renaming your home directory to match the new username

After you change the username with usermod, your home directory is still at /home/oldusername. This works fine — the system does not require the directory name to match the username. However, many people prefer them to match for clarity.

To rename the directory, log in as root or use sudo, and run:

sudo mv /home/oldusername /home/newusername

Then update the home directory path in the system files:

sudo usermod -d /home/newusername newusername

This second command tells the system where your home directory actually is. Without it, the system still thinks your home is at the old path, and you may have permission problems. Verify the change by logging out and back in — your terminal prompt should show the new path, and echo $HOME should print /home/newusername.

What happens to your files and permissions

Your files do not move or change when you run usermod. They stay exactly where they are, with the same permissions. The username change is purely a label — the system tracks file ownership by a numeric user ID (UID), not by the username itself. When you change the username, the UID stays the same, so the system still knows you own your files.

If you renamed your home directory, make sure you own it. Run ls -ld /home/newusername and check that the owner column shows your new username. If it shows a number instead (like 1000), the ownership was not updated correctly. Fix it with sudo chown newusername:newusername /home/newusername.

Fixing problems after a username change

If you renamed the home directory but forgot to update the path with usermod -d, you may see permission errors when you log in. The fix is to run sudo usermod -d /home/newusername newusername from another account or from root. Then log out and back in.

If you changed the username but the old name still appears in some places (like in the output of id or in file listings), restart the system. Some services cache the username in memory and do not refresh until reboot.

If you cannot log in after the change, boot into single-user mode and run usermod -l oldusername newusername to change it back. Then troubleshoot what went wrong before trying again.

Frequently Asked Questions

Can I change my username without losing my files?

Yes. The usermod command changes only the username label, not the files themselves or the numeric ID that tracks ownership. Your files stay in place with the same permissions. If you rename the home directory separately, make sure to update the path with usermod -d so the system knows where to find it.

What if I get a "usermod: user is currently used by process" error?

This means the user account is still logged in or running processes. Log out completely, close all terminal windows, and make sure no background services are running under that user. If you are on a desktop, log out of the graphical session entirely. Then try the usermod command again from a different user account.

Do I need to change my password after changing my username?

No. Your password is tied to your user ID, not your username, so it stays the same. You log in with your new username and your old password.

Can I change the username of the root account?

Technically yes, but it is not recommended. The root account is special in Debian, and changing its username can break system tools and scripts that expect it to be called "root". If you need a different administrative account, create a new user and add them to the sudo group instead.

What is the difference between username and UID?

The username is the human-readable name you type to log in. The UID is a number the system uses internally to track ownership and permissions. When you change the username, the UID stays the same, so file ownership does not change. This is why you can rename your account without losing access to your files.