Introduction
In this article, we will learn how to reset the forgotten password of the root user account on Ubuntu 22.04 operating system.
Prerequisites
- A VPS or Dedicated Server installed with Ubuntu 22.04
- You should have access to the Snel.com client to open the KVM console
1. Log into the KVM console
In order to change the root password you will need to log into the KVM console, depending on which server type you are using the methods may differ:
- Cloud VPS or Pure Performance VPS
- Dedicated servers with IDRAC console
- Supermicro budget server KVM access
Under the VPS service details page click onto the button Console. Now you should have the KVM console open in a new browser
2. Reboot the machine
While you have your KVM console open, reboot the server to get the GRUB menu. Note: After rebooting your server quickly go to the KVM console as GRUB menu waits only a few seconds before booting OS.
On Cloud VPS you should open the service details page of the VPS and click on the Reboot button.
If you are using dedicated server go to > Server power control > Reboot . This wil reboot the server.
3. Modify boot parameters
After rebooting the VM quickly switch to KVM console and keep pressing ESC button. You wil need to do this very quickly to get the GRUB menu.
Note: If you missed the grub screen, go ahead and reboot your server again.
- In GRUB menu, press: E which wil make it possible to edit grub boot parameters.
- Now, on the screen, you will see a few pre-configured commands, use the navigation arrow keys and go down to find the text “
ro quiet splash $vt_handoff
”
- Now delete and replace that with,
rw init=/bin/bash
as shown in the below screenshot - Once done, press CTRL + X or F10 to boot in single-user mode.
4. Got access to root shell without password
Once you boot the Ubuntu 20.04 after altering the code as mentioned in the above step you will see, you gained Shell access along with root privileges without entering any password. From here you can execute the root commands with admin rights.
To make sure we got the boot partition access as root with a read and write access use this command:
mount | grep -w /
The output will be like this:
/dev/sda5 on type ext4 (rw,realtime)
The rw in the above output shows, we have got the real-time read and write authorization of the partition.
4. Reset the Root & user Password
Finally, we have everything and now just need to change the old root password without remembering that. Simply run:
passwd
The above single command will ask you to enter the new password twice after which it will successfully change and reset your forgotten password for the root.
Well, also at the same time and place we can change the password of any specific user. For example, here we have a non-root user testuser, thus the command will be like this:
passwd testuser
5. Finally, reboot your system
Thus, we have successfully set everything that we want, and now it’s time to reboot the system to use it in the normal GUI or CLI mode.
exec /sbin/init
So, this was the quick tutorial on the password forget problem in Ubuntu 20.04, if you are facing any problems while performing the above steps, please let us know.
Conclusion
In this tutorial we have reset the password for the root user in Ubuntu 22.04 operating system.
John says
Thanks a lot
Nkululeko says
Thank you, this helped me a lot!
litianhu says
very very thinks