Change your username and password from the command line

You can change both your username and password in Kali Linux using terminal commands. The fastest way is to open a terminal, use the passwd command to change your password when ready, and use usermod to change your username if you need to. Both commands work whether you are logged in as that user or as root — though changing your own username while logged in requires a restart afterward.

The password change takes effect right away. The username change requires you to log out, restart your computer, or switch to a different user account before the system fully recognizes the new name in all places.

Key Takeaways

  • Change your password by opening a terminal and typing passwd, then entering your current password and your new password twice.
  • Change your username by typing sudo usermod -l newusername oldusername, replacing the names with your actual old and new usernames.
  • If you change your own username while logged in, you must restart your computer before the change takes full effect across all programs.
  • Changing another user's password or username requires root access or a user account with sudo permissions.
  • Your home directory name does not change automatically when you change your username — you may need to rename it separately if you want consistency.

Change your password with the passwd command

Open a terminal and type passwd at the command prompt, then press Enter. The system will ask you to enter your current password. Type it and press Enter — the text will not appear on screen as you type, which is normal. Then type your new password and press Enter. Type the new password a second time to confirm it.

If the passwords match and meet any system requirements your administrator has set, the change completes when ready. You will see a message saying "password updated successfully" or similar. The next time you log in, use your new password.

If you are changing another user's password and you have root access, type sudo passwd username, replacing username with the actual username. You will enter your own password (to confirm you have sudo permission), then set the new password for that user without needing to know their old password.

Change your username with usermod

To change a username, open a terminal and type sudo usermod -l newusername oldusername, replacing newusername with what you want the account to be called and oldusername with the current name. Press Enter and type your password when prompted. The system will not print anything if the command succeeds — no news is good news in the terminal.

If you are changing your own username while logged in as that user, you must restart your computer or log out and log back in before the change takes full effect. Some programs may still show your old username until you restart. If you are changing another user's username, they should log out first, though it is not strictly required.

The -l flag tells usermod to change the login name. The username itself changes, but your home directory (usually /home/oldusername) keeps its old name. If you want the directory name to match your new username, you will need to rename it separately using the mv command: sudo mv /home/oldusername /home/newusername.

Rename your home directory to match your new username

When you change your username with usermod, your home directory does not rename automatically. This means your home folder will still be called /home/oldusername even though your login name is now newusername. Most programs will still find your files, but the mismatch can be confusing.

To rename the directory, open a terminal and type sudo mv /home/oldusername /home/newusername, replacing the paths with your actual old and new usernames. Press Enter and type your password when prompted. After you restart your computer, your home directory will match your username.

Do this after you have changed your username with usermod, not before. If you rename the directory first, usermod may not find your home folder correctly.

What to do if you cannot remember your current password

If you are locked out of your own account, you will need to restart your computer in recovery mode or use a live Kali USB to reset it. Restart the computer and watch for a menu that appears before Kali loads — this is usually GRUB, the boot menu. Select "Advanced options" or a recovery mode entry, then choose a root shell or single-user mode.

From the root shell, you can type passwd username to set a new password for any account without needing the old one. After you set the new password, type exit and let the system finish booting normally. You can then log in with your new password.

If you do not see a recovery menu at startup, you may need to hold Shift or Escape while the computer is booting to make GRUB appear. The exact key varies by computer.

Change password and username for a different user account

If you have a user account with sudo permissions, you can change the password or username of any other account on the system. To change another user's password, type sudo passwd username and enter your own password when prompted. Then set the new password for that user.

To change another user's username, type sudo usermod -l newusername oldusername. You will need to enter your own password. The other user does not need to be logged in, and they will not be asked for their password.

After you change another user's username, tell them their new login name so they know what to use the next time they log in. If they were logged in when you made the change, they should log out and log back in for the system to recognize the new name everywhere.

Frequently Asked Questions

Do I need to restart after changing my password?

No. Your password change takes effect when ready. You can log out and log back in with your new password right away, or keep using your current session without restarting.

What happens to my files when I change my username?

Your files stay where they are. The usermod command only changes your login name, not the files themselves. Your home directory keeps its old name unless you rename it separately with the mv command.

Can I change my username without using the terminal?

Kali Linux is designed for terminal use, and the terminal is the most direct way to change your username. Some graphical tools may exist depending on your desktop environment, but they ultimately run the same usermod command behind the scenes.

What if I change my username and now programs do not recognize me?

Restart your computer. Many programs cache your username when you log in, and restarting forces them to read your new username from the system. If problems persist after restart, check that your home directory path matches your new username.

Can I change my username back if I change my mind?

Yes. Use the same usermod command with your new username as the old one and your original username as the new one: sudo usermod -l originalusername newusername. You can change it as many times as you need.