Change Your Username and Password From the Command Line
You can change both your username and password on Kali Linux using terminal commands. The fastest route is to open a terminal, use the passwd command to change your password when ready, and then use usermod to change your username if needed. Both commands work from your own user account — you do not need to restart or log out between them, though you will need to log in again with your new username the next time you start Kali.
To change your password first, open a terminal and type passwd, then press Enter. The system will ask you to type your current password once, then your new password twice. You will not see the characters as you type — this is normal and a security feature. Once you confirm the new password, the change takes effect when ready. You can now use this new password to log in.
Changing your username requires one extra step because you cannot rename the account you are currently logged into. You will need to use the sudo usermod -l newusername oldusername command, where you replace "newusername" with what you want and "oldusername" with your current name. After you run this command, log out completely, then log back in with your new username and the password you just set.
Key Takeaways
- Use the passwd command in a terminal to change your password without needing administrator privileges.
- Change your username with sudo usermod -l newusername oldusername, replacing both names with your actual old and new usernames.
- You must log out and log back in after changing your username for the system to recognize the change.
- Your password change takes effect when ready, but your username change only takes effect after you log out and log back in.
- If you forget your new password, you will need to boot into recovery mode or use another administrator account to reset it.
Step-by-Step: Changing Your Password
Open a terminal by clicking the terminal icon in your taskbar or pressing Ctrl+Alt+T. At the command prompt, type passwd and press Enter. The system will display "Current password:" and wait for you to type your existing password. Type it carefully — the characters will not appear on screen as you type.
After you press Enter, you will see "New password:". Type your new password here. Choose something you can remember but that is not a word from a dictionary or a straightforward pattern like "123456" or "qwerty". Press Enter. The system will then ask you to type the new password again to confirm you did not make a typo. Type it exactly the same way and press Enter.
If both entries match, the system will display "passwd: password updated successfully" and return you to the command prompt. Your password is now changed. The next time you log out and log back in, you will use this new password. If you stay logged in, your current session continues to work with no interruption.
Step-by-Step: Changing Your Username
Changing your username is a two-part process: first you rename the account, then you log out and back in. Open a terminal and type the command exactly as shown: sudo usermod -l newusername oldusername. Replace "newusername" with the name you want (for example, "alex") and "oldusername" with your current username (for example, "kali"). Press Enter.
The system will ask for your password — this is the sudo password, which is usually the same as your login password. Type it and press Enter. If the command succeeds, you will return to the command prompt with no message. This is normal. Your username has been changed in the system, but your current session still uses the old name.
Now you must log out. Click the power icon in the top-right corner of your screen and select "Log Out", or type exit in the terminal and press Enter. At the login screen, you will see a username field. Type your new username and press Enter or Tab, then type your password and press Enter. You are now logged in with your new username. Any files you created before the change will still be there — the system has straightforward renamed the account that owns them.
What Happens to Your Files When You Change Your Username
When you change your username with usermod -l, your home directory keeps its old name. If your old username was "kali" and you change it to "alex", your home folder will still be called "/home/kali" on disk, but the system knows it belongs to the user "alex". This usually causes no problems — your files open normally, and you can read and write to them as before.
However, some programs store paths to files or settings that reference your old username by name. If you notice that a program cannot find a file or a setting has reset, you may need to update that program's configuration. The safest approach is to also rename your home directory to match your new username, though this requires more steps and carries a small risk if something goes wrong. For most users, leaving the directory name unchanged is simpler and works fine.
Changing Your Password If You Forget It
If you change your password and then forget it, you cannot log in normally. You will need to boot Kali into recovery mode or single-user mode. Restart your computer and hold down the Shift key as it boots. A menu will appear — select "Advanced options for Kali GNU/Linux", then select the option that says "recovery mode" or "single-user mode".
The system will boot to a root prompt without asking for a password. Type passwd username, replacing "username" with your account name, and press Enter. You will be asked to type a new password twice. Once you confirm it, type exit and press Enter to continue booting normally. You can now log in with your new password.
Changing Your Password Regularly for Security
Changing your password every few months reduces the risk that someone who learned it in the past can still use it to log in. A strong password is at least 12 characters long, includes uppercase and lowercase letters, numbers, and symbols (like ! or #), and is not a word you can find in a dictionary or a pattern like your birthday.
When you create a new password, avoid reusing old passwords or making small changes to them (like changing "Password1" to "Password2"). The passwd command will reject a password that is too similar to your previous one. If you use the same password across multiple computers or services, change it on all of them at once so you do not accidentally use an old password somewhere.
Frequently Asked Questions
Do I need to be an administrator to change my own password?
No. Any user can change their own password using the passwd command without needing administrator privileges. You only need sudo if you are changing another user's password or changing your username.
What if the usermod command says "user is currently logged in"?
This means you are trying to change the username of an account that is currently in use. Log out completely from that account first, then log in as a different administrator user (or use recovery mode) and run the usermod command again.
Can I change my username and password at the same time?
Yes. Change your password first with passwd, then change your username with usermod -l. Log out and log back in with your new username and new password. Both changes will be in effect.
Will changing my username break any programs I have installed?
Most programs will work fine because they store settings in your home directory, which keeps its old name. Some programs that hardcode your username in their configuration may need adjustment, but this is rare. If a program stops working after you change your username, check its settings or configuration file for references to your old username.
What if I type the usermod command wrong?
If you make a typo and the command fails, nothing changes. The system will display an error message. Read it carefully, correct your command, and try again. The most common mistake is swapping the old and new usernames — make sure the new name comes first and the old name comes second.