Change your username and password from the command line
Kali Linux stores usernames and passwords in system files that only the root user can edit directly. To change either one, you open a terminal and run commands that modify those files — you do not navigate a settings menu the way you would in Windows or macOS. The process takes about two minutes and requires you to know your current password.
Both changes happen in the terminal. If you are new to the command line, the steps below show you exactly what to type and what output to expect. The commands themselves are safe; they straightforward rewrite the files that hold your login information.
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 usermod -l newusername oldusername while logged in as root, where newusername is what you want and oldusername is what you have now.
- Changing your username also requires you to rename your home directory from /home/oldusername to /home/newusername using the mv command.
- If you forget your password, you will need to boot into single-user mode or use a live USB to reset it, because there is no password recovery built into Kali.
- Test your new password or username by logging out and logging back in before you close the terminal, so you catch any mistakes while you still have access.
How to change your password
Open a terminal by pressing Ctrl + Alt + T or clicking the terminal icon in your taskbar. Type the word passwd and press Enter. Kali will ask you to enter your current password — type it and press Enter. You will not see the characters as you type; this is normal.
Next, Kali asks for your new password. Type it and press Enter. Then type it again to confirm. If the two new passwords match, Kali prints a message saying the password has been updated. If they do not match, it tells you and asks you to try again.
Your new password takes effect when ready. You do not need to restart the computer or log out. The next time you log in — or the next time you run a command that requires your password — use the new one.
How to change your username
Changing your username is more involved because it lives in multiple places: the user account itself, your home directory, and sometimes in configuration files. The safest way is to do it while logged in as root.
Open a terminal and type su - to switch to the root user. Enter the root password when prompted. Then type this command, replacing oldusername with your current username and newusername with what you want:
usermod -l newusername oldusername
Press Enter. If the command succeeds, you see no output — that is normal. Now you need to rename your home directory. Type this command:
mv /home/oldusername /home/newusername
Press Enter. Again, no output means success. Type exit to leave the root session and return to your regular user account.
Why you need to rename your home directory
Your home directory is the folder where Kali stores your files, desktop settings, and process preferences. It is located at /home/yourusername. When you change your username with the usermod command, the system updates your account name but does not automatically rename the folder.
If you skip this step, your username will be newusername but your files will still be in /home/oldusername. Some programs may not find your settings, and you may see permission errors when you try to access your own files. Renaming the directory with the mv command fixes this mismatch.
Test your changes before you close the terminal
After you change your password or username, log out and log back in while the terminal is still open. This way, if something went wrong, you still have access and can fix it. Press the power icon in the top-right corner and select Log Out. At the login screen, enter your new username and new password.
If you log in successfully, you are done. If the login fails, switch to another virtual terminal by pressing Ctrl + Alt + F2 (or F3, F4, etc.). Log in with your old credentials if they still work, or with root if you know the root password. Then undo the changes by running the commands in reverse — for example, usermod -l oldusername newusername to change the username back.
What to do if you forget your password
Kali does not have a built-in password recovery tool like some other operating systems. If you forget your password and you do not know the root password, you will need to boot from a live USB or DVD and reset it manually. This requires you to have created a bootable Kali USB beforehand, or to have access to another computer where you can create one.
The process involves booting into single-user mode or mounting your hard drive from the live environment, then editing the password file directly. This is beyond the scope of a basic password change, but the Kali documentation and community forums have step-by-step guides if you need them. The key point: do not lose both your user password and your root password, because recovering from that requires more advanced steps.
Why Kali stores passwords differently than other systems
Kali is built on Debian Linux, which uses a standard system for managing user accounts. Passwords are not stored as plain text; instead, they are run through a one-way mathematical function called a hash. When you log in, Kali hashes what you type and compares it to the stored hash. If they match, you are in.
This is why you cannot recover a forgotten password by looking it up somewhere — even Kali's administrators cannot see what your password is. They can only reset it by creating a new hash, which is what you do when you run the passwd command. Understanding this helps explain why the process requires your current password: Kali needs to verify that you are really the account owner before it lets you change it.
Frequently Asked Questions
Can I change my username without changing my password?
Yes. The usermod and mv commands change only your username. Your password stays the same. You can run them independently — change your username today and your password next week, or vice versa.
What happens to my files when I rename my home directory?
Your files do not move or change. The mv command straightforward renames the folder from /home/oldusername to /home/newusername. Everything inside stays exactly as it was. Kali automatically updates the paths so your applications can still find your settings and documents.
Do I need to be root to change my password?
No. Any user can change their own password by running passwd without becoming root. You only need root access to change someone else's password or to change your username with usermod.
What if the usermod command says the username is already in use?
This means another user account already has that name. Choose a different username and try again. You can see all usernames on your system by typing cat /etc/passwd in a terminal.
Can I change my username while I am logged in?
Technically yes, but it is risky. If something goes wrong mid-change, you may lose access to your account. The safer approach is to log in as root, make the changes, then log out and log back in as your new username to test. This way you always have a working account to fall back on.