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 a regular user or as root — though changing your own username requires extra steps to avoid locking yourself out.

Start by opening a terminal. Press Ctrl + Alt + T, or click the terminal icon in your process menu. If you are changing your own password, type passwd and press Enter. The system will ask you to enter your current password, then prompt you twice for your new password. Type carefully — the text will not appear on screen as you type.

If you are changing another user's password and you have root access, type passwd username (replace "username" with the actual name) and press Enter. You will not need to enter the old password — you can set a new one directly. This is useful if you have forgotten a password or are administering multiple accounts.

Key Takeaways

  • Use the passwd command in a terminal to change your password; type passwd alone to change your own, or passwd username to change another user's password if you have root access.
  • Changing your own username requires logging in as root or using sudo usermod -l newname oldname, then renaming your home directory with sudo mv /home/oldname /home/newname.
  • After changing your username, you must also update the home directory path by editing the passwd file or using usermod -d, otherwise your system may not find your files.
  • Log out and back in after changing your username to confirm the change took effect and to avoid permission errors on your home directory.
  • If you change your own username while logged in, you may lose access to files until you log out and log back in with the new name.

Change your username using usermod

To change a username in Kali Linux, you need root privileges. If you are changing your own username, you must either log in as the root user first, or use sudo to run the command with elevated permissions. Open a terminal and type sudo usermod -l newusername oldusername, replacing "newusername" with what you want and "oldusername" with the current name. Press Enter and type your password when prompted.

This command changes the login name in the system files, but it does not automatically rename your home directory. You must do that separately. Type sudo mv /home/oldusername /home/newusername and press Enter. This moves all your files, settings, and documents from the old directory to the new one.

After renaming the directory, you should also update the home directory path in the system files. Type sudo usermod -d /home/newusername newusername and press Enter. This tells the system where to find your home directory when you log in. Without this step, you may see permission errors or your desktop may not load correctly.

Log out and verify the changes took effect

After changing your username, log out of your session completely. Click the power icon in the top-right corner, select "Log Out", and confirm. Do not just close the terminal — you need to end your entire session so the system recognizes the new username.

At the login screen, enter your new username and your password. If you changed only the password and kept the same username, just enter the new password. If you changed the username, use the new name. If the login fails, go back and check that you ran all the commands correctly, especially the directory rename and the home path update.

Once you are logged in, open a terminal and type whoami to confirm your username is correct. The output should show your new username. If it still shows the old name, the change did not take effect — log out again and try logging in once more.

Change your password as the root user

If you are logged in as root, you can change any user's password without knowing their current password. This is useful if you administer a Kali system for multiple people or if you have forgotten your own password and booted into root recovery mode. Open a terminal and type passwd username, replacing "username" with the account you want to change. Press Enter.

The system will not ask for the old password. Instead, it will prompt you to enter the new password twice. Type the new password carefully both times — remember that the text will not appear as you type. Press Enter after each entry. The password is now changed, and the user can log in with their username and the new password on their next login.

Avoid common mistakes when changing your username

The most common mistake is changing the username but forgetting to rename the home directory or update the home path. If you do this, you will log in successfully, but your desktop may not load, or you may see "Permission denied" errors when trying to access your files. The system is looking for files in the old directory path, which no longer exists under your new username.

Another mistake is changing your own username while you are still logged in and then trying to use sudo or access files before logging out. Your session is still tied to the old username, so permissions may be confused. Always log out completely after changing your own username, then log back in with the new name.

If you change your password and then forget it, you can reset it by booting into single-user mode or recovery mode, logging in as root, and using the passwd command to set a new one. This requires physical access to the machine and is a last resort, but it is possible.

Use the GUI to change your password instead

If you prefer not to use the terminal, Kali Linux also offers a graphical way to change your password. Click the power icon in the top-right corner and select "Settings". Look for "Users" or "Accounts" in the left menu. Click on your username, then look for a "Change Password" button or option. You may need to click a lock icon first to unlock the settings, and you will be asked to enter your current password for security.

The GUI method works only for changing your own password, not for changing your username or another user's password. For those tasks, you must use the terminal commands described above. The GUI is simpler if you just want to update your password and do not need to change your login name.

Frequently Asked Questions

What happens if I change my username but forget to rename my home directory?

Your login will succeed, but you will not be able to access your files, and your desktop may not load. The system looks for your home directory at /home/newusername, but your files are still at /home/oldusername. Rename the directory using sudo mv /home/oldusername /home/newusername and update the home path with sudo usermod -d /home/newusername newusername, then log out and back in.

Can I change my username without using the terminal?

Kali Linux does not offer a graphical tool to change your username. You must use the terminal and the usermod command. The GUI settings only allow you to change your password. If you are not comfortable with the terminal, changing your password through the GUI is an option, but renaming your account requires command-line work.

Do I need to be root to change my own password?

No. Any user can change their own password by typing passwd in a terminal. You will be asked to enter your current password first, then your new password twice. You do not need root access for this. However, if you want to change another user's password or your own username, you do need root or sudo privileges.

What if I am locked out of my account after changing my username?

Boot into single-user or recovery mode by restarting your computer and holding Shift during startup. Select "Recovery mode" from the menu. Log in as root when prompted. Use passwd username to reset the password, or use usermod to fix the username and home directory paths. Then reboot normally and try logging in again.

Will changing my password affect my sudo access?

No. Your sudo access is tied to your username and your membership in the sudo group, not to your password. Changing your password does not affect whether you can use sudo. You will straightforward use your new password the next time sudo asks you to authenticate.