The usermod command is the standard way to change your username

To change your username in Kali Linux, you use the usermod command from the terminal. This command modifies user account properties, including the login name. The process takes about two minutes and requires you to have administrator (sudo) access on your machine.

The basic command structure is straightforward: you tell usermod to change the login name (the -l flag) from your old username to your new one, then specify which account to modify. You run this as the root user or with sudo, which means you need to know the administrator password.

Before you start, log out of the account you want to rename. You cannot change the username of an account while you are logged into it — the system will not allow modifications to an active session. If you are the only user on the machine, you will need to log in as root or use a different method.

Key Takeaways

  • Log out of the account you want to rename before making any changes, because you cannot modify an active user session.
  • The command sudo usermod -l newusername oldusername changes the login name, but does not automatically rename the home directory.
  • After changing the username, you must also rename the home directory from /home/oldusername to /home/newusername using the mv command.
  • Update the ownership of the renamed home directory so the new username owns all its files and folders.
  • Test the change by logging in with your new username to confirm everything works before you consider the task complete.

Step-by-step process to rename your account

Start by logging out of the account you want to change. Click the power icon in the top-right corner of the screen, select "Log Out", and confirm. You will return to the login screen.

Log in as root or as a different user account that has sudo access. If you set up Kali with a root password during installation, log in as root directly. If you created a standard user account during setup, log in with that account instead — you will use sudo before each command.

Open a terminal. Right-click on the desktop and select "Open Terminal Here", or click the terminal icon if one is visible on your taskbar. You now have a command prompt where you can type the usermod command.

Type the command to change the username. If you are logged in as root, type: usermod -l newusername oldusername. Replace newusername with what you want the new login name to be, and oldusername with your current login name. If you are logged in as a different user, add sudo at the start: sudo usermod -l newusername oldusername. Press Enter and type your password if prompted.

Rename the home directory to match the new username

Changing the username with usermod only updates the login name in the system files. Your home directory — the folder that stores your documents, downloads, and settings — still has the old name. You must rename this folder so the system can find your files.

In the same terminal, type: mv /home/oldusername /home/newusername. This moves (renames) the entire home directory from the old path to the new one. Press Enter. If you are not logged in as root, add sudo at the start: sudo mv /home/oldusername /home/newusername.

The command completes silently if it succeeds — you will see no confirmation message, just a new command prompt. If you see an error like "cannot stat", it usually means you typed the old username incorrectly or the directory does not exist at that path.

Update file ownership for the renamed directory

When you renamed the home directory, the files inside still belong to the old username in the system's records. You need to change the ownership so the new username owns all those files. Without this step, you may see permission errors when trying to access your own files.

Type: chown -R newusername:newusername /home/newusername. The -R flag means "recursive" — it changes ownership of the directory and everything inside it. Replace newusername with your new login name. If you are not root, add sudo: sudo chown -R newusername:newusername /home/newusername. Press Enter.

Again, a successful command produces no output. You will straightforward see a new command prompt. If you see "Operation not permitted", you are not running the command with enough privileges — make sure you used sudo or that you are logged in as root.

Verify the change by logging in with your new username

Close the terminal and log out of your current session. Click the power icon and select "Log Out". At the login screen, type your new username and the password you have always used — the password does not change, only the login name does.

If you log in successfully and see your desktop with all your files and settings intact, the rename is complete. Open a file manager and navigate to your home directory to confirm your documents are there. Check that you can create new files and folders without permission errors.

If you see a login error or cannot access your files, log back in as root or as a different user and review the steps above. The most common issue is a typo in the username or a path that was entered incorrectly. Double-check that the home directory was actually renamed by typing ls /home in the terminal — this lists all user directories and will show you what names currently exist.

What to do if you cannot log in after the change

If the rename went wrong and you cannot log in with your new username, you can still fix it. Log in as root or as a different user account. Open a terminal and type ls /home to see what directories exist. If you see both the old and new directory names, the move command did not complete — you may have run out of disk space or encountered a permissions issue.

If the directory was renamed but you still cannot log in, check the ownership again with ls -l /home. This shows who owns each directory. If the new directory is not owned by the new username, run the chown command again, making sure you typed the username correctly.

If you want to undo the change entirely, you can rename everything back. Type usermod -l oldusername newusername to change the login name back, then mv /home/newusername /home/oldusername to rename the directory, then chown -R oldusername:oldusername /home/oldusername to fix ownership. Log out and try logging in with your original username.

Frequently Asked Questions

Does changing my username change my password?

No. Your password stays the same — only the login name changes. You will log in with your new username and your existing password. If you want to change your password as well, you can do that after logging in by typing passwd in the terminal.

What if I have files outside my home directory?

Files in other locations (like /opt or /var) are not affected by renaming your home directory. However, if those files are owned by your old username, they will still show that old name in permission listings. For most users, this does not cause problems. If you need to change ownership of files elsewhere, use chown with the full path to that location.

Can I change the username while I am logged in?

No. The system will not allow you to modify an active user session. You must log out first, then log in as root or a different user to run the commands. This is a safety feature to prevent the system from becoming unstable.

Will changing my username affect my installed programs?

Most programs will continue to work normally because they do not depend on your username. However, some applications store settings in your home directory using the old username path. After logging in with your new username, these programs may create new settings folders. You can usually copy your old settings to the new location if you want to keep them.

What does the -R flag in the chown command do?

The -R flag stands for "recursive" and tells chown to change ownership of the directory and every file and subfolder inside it. Without -R, chown would only change the directory itself, leaving all your files still owned by the old username. Always use -R when changing ownership of a home directory.