The fastest way to change your Kali username

The quickest method is to use the usermod command, which changes your username without touching your home directory or files. Open a terminal and run:

sudo usermod -l newusername oldusername

Replace newusername with what you want and oldusername with your current login name. You will need to enter your password because sudo requires administrator rights. After you run this command, log out completely, then log back in with your new username — your password stays the same.

This method works because usermod -l changes only the login name in the system files. Your home directory, file ownership, and permissions all stay tied to your user ID number, not your name, so nothing breaks.

Key Takeaways

  • The sudo usermod -l newusername oldusername command changes your username without affecting your files or home directory.
  • You must log out and log back in after running the command for the change to take effect.
  • If you also want to rename your home directory from /home/oldusername to /home/newusername, use sudo usermod -d /home/newusername -m oldusername after the first command.
  • Always run username changes from a terminal where you have sudo access, and avoid making changes while logged in as the user you are changing.

Renaming your home directory at the same time

If you want your home folder name to match your new username, you need a second command after the first one. Run:

sudo usermod -d /home/newusername -m oldusername

The -d flag sets the new home directory path, and the -m flag tells the system to move all your files from the old location to the new one. This keeps all your documents, downloads, and configuration files in the right place.

Do this in the same terminal session, one command after the other. If you close the terminal between them, the second command will still work — it just moves the directory whenever you run it.

Why you should not edit files directly

You might find guides that tell you to edit /etc/passwd or /etc/shadow by hand. Do not do this in Kali Linux. These files control who can log in and how, and a single typo can lock you out of your system entirely.

The usermod command does the same thing but checks your syntax before writing anything. If something goes wrong, you get an error message instead of a broken system. It is also safer because the command knows about all the places a username appears — not just the obvious ones.

What happens to your files and permissions

Linux stores file ownership by user ID number, not by name. When you change your username with usermod, your user ID stays the same, so all your files still belong to you. You will not lose access to anything, and you will not have to fix permissions by hand.

If you list your files with ls -l right after the change, you might see your old username still displayed for a moment. This is just because the system is still reading the old name from its cache. Restart your terminal or run hash -r to clear it, and the new username will show up.

Changing the username for a different user

If you are an administrator and need to change someone else's username, the same commands work — you just use their old username instead of your own. You do not need to be logged in as that user.

For example, to change a user named student to intern, run:

sudo usermod -l intern student

That user will not be able to log in with their old name after this. If they are currently logged in, they stay logged in until they log out. The next time they try to log in, they must use the new username.

Reverting a username change

If you change your mind or made a mistake, you can change it back the same way. Just swap the old and new names in the command:

sudo usermod -l originalusername newusername

This works because usermod does not care which name is "original" — it just swaps whatever you tell it to. Your files, permissions, and home directory stay exactly where they are.

Frequently Asked Questions

Do I need to restart Kali after changing my username?

No. You only need to log out and log back in. A full restart is not necessary, though it does not hurt. Logging out clears your session and forces the system to read your new username from the login screen.

Will my password change when I change my username?

No. Your password is stored separately from your username and stays exactly the same. You log in with your new username and your old password.

What if I get a "usermod: user is currently logged in" error?

You are trying to change the username of a user who is currently logged in. Log out as that user first, then run the command. You can change your own username from a terminal, but you must log out afterward before you can log back in with the new name.

Can I change my username without changing my home directory name?

Yes. Use only the first command: sudo usermod -l newusername oldusername. Your home directory will stay at /home/oldusername even though your login name is now newusername. This is unusual but harmless.

What if I forgot my old username?

Run whoami in a terminal to see your current username. If you are logged in, this tells you exactly what name to use in the usermod command.