Changing the root password on Kali Linux is a critical practice for administrators and ethical hackers as it makes it harder for hackers to get into the system. However, security audits and penetration testing are the main purposes of Kali Linux.
How To Change Root Password in Kali Linux
There are two main methods to change the root password on Kali Linux, which will be thoroughly covered in this post. Moreover, there is a GUI method for changing the password but it is only limited to changing the admin account password or other non-admin accounts.
1: Through Kali Linux GRUB Menu
The Grand Unified Bootloader allows users to choose which operating system to boot in case of multiple ones installed. Even with a single OS, sometimes there might be different kernel versions available. The GRUB menu allows you to choose the specific kernel you want to use for booting. Moreover, the root password can be changed through the GRUB bootloader. For that first restart the Kali Linux:
Now at the startup, you will see the Kali Linux Boot Screen. Here press the E key from your keyboard to go to the GRUB menu:
Now move the cursor to the code line: ro quiet splash. It sets parameters that mount the root filesystem as read-only, suppresses boot messages for a cleaner boot process, and displays a splash screen instead of text messages.
Next, replace this code line with the below-given line of code:
rw init=/bin/bash
This will set the system to boot with the root filesystem mounted as read-write (rw) and initialize the system with the Bash shell (/bin/bash) instead of the usual init process:
Next, execute the below command first to verify the permissions for the drive:
mount | grep -w /
Now to change the root password on Kali Linux use the below command syntax:
passwd <root-account-name>
Once you have changed the password successfully execute the below command which replaces the current shell with the system’s initial process, effectively starting the system’s primary process manager without creating a new process:
exec /sbin/init
2: Through Terminal
The second method for changing the root account password of Kali Linux is by using the passwd command. This method is the easiest one among all the other methods. So to change the Kali Linux root password execute:
sudo passwd root
Once the command is executed just enter your new desired password two times and it will be changed successfully:
On the other hand, if you want to change the password of any other Kali Linux user account having administrator privileges then use the passwd command along with its username:
passwd <root-user>
3: Through GUI (Administrator Account)
The third and last way to change the root password in Kali Linux is through the Users and Groups settings. This method is for those users who are not well equipped with knowledge of using commands in Kali Linux. First, click on the settings option and select the Users and Groups option:
Now here you select your administrator account user. Next, click on the change option right next to the password option:
Here first enter your current password and then set your desired password. Next, click on OK to apply the changes to the admin password:
Here you can also set the password generated by Kali Linux. For that simply select the Generate random password option. Next, click on the Generate option and the password will be generated. You can generate multiple combinations of passwords depending on your preference:
One thing to note here is that these randomly generated passwords are no doubt hard to crack but they can also be hard to remember. So choose wisely.
Note: Another thing to note here is that this method is only for changing the admin user password in Kali Linux. The root account has unrestricted access to all files, directories, and system resources and is also named a superuser account. An admin account typically has elevated privileges to perform administrative tasks but with limitations compared to the root.
Conclusion
On Kali Linux, there are two primary ways to change the root password one is via the GRUB menu, and the other is through using the passwd command. However, to change the password of an administrator account of Kali Linux you can do it through the Users and Groups settings. The recommended way to change the root password is by using the passwd command along with the root username in the terminal.