How to reset Kali Linux Password [Easy Guide]

How To Reset Your Password In Kali Linux

So, you are one of those poor souls that have forgotten the password to your Kali Linux machine. Before you wipe that disk and whip up another Kali Installation let me show you another way you can reset your password.

Be it your virtual machine or just another regular machine, this solution will work for you regardless of your use. So, let’s keep going and hack our way to that password reset!

Related topic: How to Reset root Password in Ubuntu?

Changing the GRUB options

Forgetting a password is a frustrating thing in itself, but forgetting a login password is even more frustrating. Now, you have forgotten the login password and hence cannot even log into your own machine. If you are using a virtual machine however taking a snapshot is a bit of good advice.

Continue after you’re done. Now, the first thing you’re going to do is to restart your machine, and while the machine is still booting up you might notice a screen that pops up, go ahead and press one of the arrow keys on your machine just to stop the machine from continuing to boot.

Message while booting
Message while booting

Now highlight the option which says “Kali GNU/Linux” and press the “e” button. You will be editing this GRUB entry. Now go ahead and find the line that starts with the word “Linux”.

Find the line that starts with the word "linux"
Find the line that starts with the word “Linux”

This is the line that is telling the kernel to boot and the boot arguments. We will be editing this in such a way that the kernel will boot and let us into a terminal, in order for us to reset the password.

Now the first thing we’re going to change is the one where it says “ro”, which means read-only. You can navigate to the line by simply using the arrow keys We will change that to “rw” which stands for read and write. Also at the end, we will need to add some text, see the below box for that:

init=/bin/bash

What this piece of code is doing is that as soon as the kernel is finished booting run this command which will open up a bash shell to allow us to interact with the file system. Once you have done these two modifications press the Control and the X button at the same time. The machine will now boot with the GRUB changes you just made.

Changing the root password using the passwd command

Now you will be dropped into a shell with your filesystem mounted in read-write mode. So now we can simply run the passwd command to change our password.

passwd

Running the command will prompt you asking your new root password. Give it that, and you will again be prompted to retype the same password just for confirmation.

Now if you want to change the password for a different user, simply run the passwd command with the username for which you want to change the password:

passwd <username>

Give the new password and again retype and confirm your new password. Now reboot your machine and simply login using the new password.

Summary

Now you guys know how to change your root password for Kali Linux whether in a virtual machine or just a regular PC by simply configuring the GRUB options and logging into a bash shell and then using the passwd command. This allows us to never lose valuable sessions in a Kali machine. As always, thanks for reading and happy hacking!