Figuring out how to reset forgotten root password on Debian 11 is essential to getting back access to your system, and we’re here to help you do that.
There are situations where you may have forgotten your root password on Debian 11, and it could be quite annoying. The good news is that a workaround exists to reset your password in case you don’t remember the old password.
This article will discuss how to reset forgotten root password on Debian 11. A Debian system with physical access is required to perform the steps below. In addition, the steps discussed below apply to Bedrock Linux as well.
Why resetting the forgotten root password is important
The root user is the most privileged in your system. You can no longer perform administrative tasks if you lose the root password. Generally, this happens when you last used the root password quite a while ago.
When you add a general user in the sudo group, you don’t usually need a root user for various tasks. However, you may require a root user for privileged tasks.
How to Reset Forgotten Root Password on Debian 11
Fortunately, we can use a workaround to access the root user and change the password. We will now discuss various steps on how to reset forgotten root password on Debian 11. Follow the steps below:
Step 1 – Open the Grub menu
The first step is to open the Grub menu. For this purpose, follow the steps below:
- Restart your computer.
- As the system is booting, press hold and shift on your keyboard. You must do it quickly; it will take a few seconds before booting the operating system.
- You will see the grub menu.
- If you miss the grub menu, you must restart the system.
Note: Depending upon your hardware, you may need to use another key besides the shift to see the grub menu
Step 2 – Edit the Grub menu
Select the respective boot partition. Now we will edit the grub menu. This will allow editing the default boot entry of your Debian. You can edit the menu by pressing your keyboard’s ‘e’ key. You will be taken to the editor. Don’t make e next step.
Note: Pressing ‘e’ on the grub menu will edit the kernel command line parameter
Step 3 – Add rw init=/bin/bash
Follow the steps below to add
- Use your arrow key to move to the line containing the text Linux. This should precede the line
/boot/vmlinuz-*specifying the UUID.
- Type the following at the end of this line:
Here, we have specified a shell script location /bin/bash.
- Once you have made the changes, reboot your system. You can boot the system by pressing
Ctl + Xor
F10. Note that after this step, you will be booted into chroot environment.
The following lines show where to edit the grub menu.
Step 4- Check if you have root file access
Once your system is booted, you can access the Debian shell without a root password. You need to check if you can access the file system where the operating system (OS) has been installed. Type the following command on your Terminal:
$mount | grep -w /
Note down the output. If you see “rw,realtime, ” you will have real-time read and write access to the file system.
Step 5 – Remount the root file system with rw attributes
Note that while booting in the previous step, you may have only read-only access rights. To understand how to reset forgotten root password on Debian 11, you will need to have the read-write access. Run the following command below that will remount the root file system with rw attributes:
:/# mount -n -o remount,rw /
Step 6 – Reset the root user password
Finally, you can change the root user password. For this purpose, type the following command on the Terminal:
You will be asked to provide a new password. Type the new password and confirm the password. The following message will be shown on stdout:
passwd: password updated successfully
Step 7- Reset the password of other users
If you want to change the password other than the root user, mention the user name. The syntax is as follows:
For instance, you can change the password of the user Debian with the following command:
Step 8 – Reboot the system
Finally, you can reboot the system. You can reboot the system by typing the following command on the Terminal:
Then, press the enter key. Once you have booted the system, you can log in with the new password.
Note: You can reboot the system using Ctl + Alt + Del keys.
Tips for preventing forgotten root passwords on Debian 11
While forgetting the root password can be quite frustrating, there are a few things you can do to prevent it from happening again in the future:
- Use a password manager: A password manager can generate strong and unique passwords for all your accounts, including the root account. This way, you don’t have to remember the password, and you can access it whenever you need it.
- Change your password regularly: Regularly changing your password can reduce the risk of someone gaining access to your system with an old password.
- Write it down: If you’re worried about forgetting your root password, you can write it down and store it somewhere safe, like a password manager or a secure physical location.
- Use a recovery key: Many Linux distributions, including Debian 11, allow you to set up a recovery key that you can use to reset your root password if you forget it. Make sure to keep the recovery key somewhere safe and secure.
By following these tips, you can reduce the likelihood of forgetting your root password and ensure that you always have access to your system when you need it.
In this article, we have discussed the various steps on how to reset forgotten root password on Debian 11. Access to the root password is important for multiple reasons, as it enables performing administrative tasks on your computer.
The general process required to gain access to the root is first to edit the grub menu to gain access to the shell without a password, then change the access mode to the file system as read-write, and finally, change the password. We hope you liked the article.
If this guide helped you, please share it.