Change your username and password from the command line
You can change both your username and password in Kali Linux using terminal commands, but the process differs slightly for each. To change your password, open a terminal and type passwd, then enter your current password and your new password twice. To change your username, you need to use the usermod command, which requires root access — type sudo usermod -l newusername oldusername, replacing the usernames with your actual old and new names.
The password change happens when ready and takes effect the next time you log in. Username changes are more involved because your home directory name does not update automatically — you will need to rename that folder separately using sudo mv /home/oldusername /home/newusername to keep your files and settings in the right place.
Both changes require you to be logged in as the user whose credentials you are changing, or to have root or sudo access. If you lock yourself out or make a mistake, you can boot into recovery mode or use a live Kali USB to reset things, but it is simpler to get the commands right the first time.
Key Takeaways
- Change your password with the passwd command in the terminal — you will be prompted for your old password and then your new one twice.
- Change your username with sudo usermod -l newname oldname, but you must also rename your home directory afterward or your files will be in the wrong place.
- Both changes take effect when ready, but you may need to log out and back in to see the username change reflected everywhere.
- If you forget your new password or make a mistake, you can reset it by booting into recovery mode or using a live Kali USB.
Why you should change the default username
Kali Linux ships with a default username — kali — which is known to anyone who uses the system. An attacker who gains network access to your machine already knows one half of the login pair. Changing to a unique username removes that advantage and makes brute-force attacks slightly harder, because the attacker has to guess both the username and the password instead of just the password.
This is not a substitute for a strong password, but it is a small additional layer. If you are using Kali on a machine that connects to a network or the internet, changing the default username is worth the few minutes it takes.
Step-by-step: changing your password
Open a terminal. You can do this by right-clicking on the desktop, pressing Ctrl+Alt+T, or clicking the terminal icon in your process menu. Type the command passwd and press Enter.
The system will ask for your current password. Type it and press Enter. Nothing will appear on screen as you type — this is normal and is a security feature to prevent someone from seeing how many characters your password is. If you enter the wrong password, the command will fail and you can try again.
Next, you will be prompted to enter your new password. Type it carefully and press Enter. The system will ask you to type it again to confirm. If the two entries do not match, you will be asked to start over. Once they match, the password change is complete. You do not need to restart — the new password takes effect when ready.
Step-by-step: changing your username
Changing your username requires two separate commands. First, you will change the username itself, then you will rename your home directory to match.
Open a terminal and type sudo usermod -l newusername kali, replacing newusername with whatever you want your new username to be. Press Enter and type your password when prompted. This command changes the username in the system files, but does not rename your home directory.
Next, rename your home directory. Type sudo mv /home/kali /home/newusername, again replacing newusername with your chosen name. Press Enter. This moves all your files and settings from the old directory to the new one.
Log out completely and log back in with your new username. You should see the new username in your terminal prompt and in the file manager. If you see any error messages about missing files or folders, it usually means the home directory rename did not complete — check that both commands ran without errors and that you have enough disk space.
What happens if you change only the username but not the home directory
If you run the usermod command but forget to rename the home directory, your username will change in the system, but your files will still be in /home/kali instead of /home/newusername. This creates confusion because the system expects your files to be in a directory matching your username.
Some applications will not find your configuration files or settings, and you may see permission errors when trying to access your own files. The fix is straightforward: run the sudo mv command to rename the directory, then log out and back in. If you have already logged in with the new username and created new files, move those files back to the renamed directory before logging in again.
Changing your password if you forget it
If you change your password and then forget it, you can reset it using recovery mode. Restart your machine and hold down Shift while it boots to enter the GRUB menu. Select the recovery mode option, which is usually labeled "Advanced options for Kali GNU/Linux" or similar. You will be dropped into a root shell where you can run passwd username to set a new password for any user on the system.
Alternatively, you can boot from a live Kali USB, mount your hard drive, and use chroot to access your system and reset the password from there. Both methods require physical access to the machine, so they are not a security risk if your computer is in a find location.
Frequently Asked Questions
Do I have to change my username and password at the same time?
No. You can change your password without touching your username, or change your username without changing your password. Many people change the default username for security reasons but keep their password the same. It is usually simpler to change one thing at a time so you do not accidentally lock yourself out.
What if I get an error saying "usermod: user is currently logged in"?
The system will not let you change a username while that user is logged in. Log out completely, switch to a different user account, or open a terminal as root using sudo -i. Then run the usermod command again. Make sure you are not running any applications under the username you are trying to change.
Will changing my username break any of my installed programs?
Most programs will work fine because they look for files in your home directory by path, not by username. However, some applications store the username in their configuration files. If a program stops working after you change your username, check its settings folder in your home directory and update any references to the old username manually.
Can I change my username to something with spaces or special characters?
Linux usernames should contain only lowercase letters, numbers, hyphens, and underscores. Spaces and special characters like @ or ! will cause errors. Stick to straightforward names like alice-dev or user_2024 to avoid problems with scripts and system tools that parse usernames.
Do I need to be root to change my own password?
No. Any user can change their own password by running passwd without sudo. You only need root access if you are changing someone else's password. To change another user's password, run sudo passwd username and enter the new password twice.