Reset Linux Root Password on Debian 12 Bookworm | Easy Steps
This tutorial will guide you through the process to Reset Linux Root Password on Debian 12 Bookworm. There are times when even experienced system administrators forget the root password, making it impossible to log in and manage the system. This article focuses on recovering the lost password before the login screen appears. We’ll start with the method described on the Orcacore website, which involves accessing the Grub menu, and then explore alternative solutions.
To begin the root password recovery process, you’ll need to restart your Debian server. Once the system restarts, immediately press and hold the Shift key on your keyboard. This action will present you with the Grub menu, the bootloader interface.
Now, let’s follow these steps to regain access to your system.
At the Grub menu, press the ‘e’ key on your keyboard. This will allow you to edit the Grub’s boot prompt. It’s crucial to be careful here; avoid making any unintentional changes or deletions. This editor allows you to modify the boot parameters temporarily. Proceed to the next step once you’ve accessed the editor.

Using your arrow keys, navigate to the end of the line that begins with "Linux". At the very end of this line, add the following: rw init=/bin/bash
.
rw init=/bin/bash
This modification instructs the system to boot into a bash shell with root privileges, bypassing the usual login process.

After adding the syntax, boot your system with these altered settings. You can achieve this by pressing Ctrl+X or F10.
Root Shell Access on Debian 12
At this point, you will be presented with a Debian 12 shell with root access, without requiring a password. It’s essential to verify that your user has read and write access to the file system where the operating system is installed.
Execute the following command:
mount | grep -w /
The output should include (rw,realtime)
, indicating that you have real-time read and write access to the file system. This confirms that you can proceed with modifying the root password.
Change Root Pass on Debian 12
Now, you can easily change the root password on your Debian 12 system using the following command:
passwd
The system will then prompt you to enter the new password twice for confirmation.
To change the password for a user other than root, specify the username after the passwd
command. For example:
passwd <username>
Replace <username>
with the actual username whose password you want to reset.
Once you have successfully reset the password, restart your system to log in with the newly set password. To reboot, use the following command:
exec /sbin/init
Press the Enter key.
After the reboot, you can log in and access your system with the updated root password.
That concludes the process.
Conclusion
Resetting the root password manually is often the only way to regain access to your system. You’ve now learned how to Reset Linux Root Password on Debian 12 Bookworm directly from the Grub Menu.
Here are some related articles you might find helpful:
How To Change SSH Port on Debian
How To Check HTTPS Port 443 is Open on Linux
Fix error Group ‘development-tools’ is not available
Alternative Solutions for Resetting the Root Password
While the Grub method is effective, there are other approaches to Reset Linux Root Password on Debian 12 Bookworm. Here are two alternative solutions:
1. Using a Live CD/USB
This method involves booting your system from a live Linux distribution (e.g., Ubuntu, Debian Live) on a CD or USB drive. Once booted into the live environment, you can mount your Debian 12’s root partition and modify the root password using chroot
.
Steps:
- Boot from Live Media: Insert the Live CD/USB and boot your system from it. You might need to adjust your BIOS/UEFI settings to change the boot order.
- Identify the Root Partition: Open a terminal in the live environment and use
lsblk
orfdisk -l
to identify the partition where your Debian 12 system is installed. Look for a partition with a large size and a filesystem type likeext4
. Let’s assume it’s/dev/sda1
. -
Mount the Root Partition: Create a mount point and mount the identified partition:
sudo mkdir /mnt/debian sudo mount /dev/sda1 /mnt/debian
-
Chroot into the Debian System: Use
chroot
to change the root directory to the mounted partition. This makes the mounted partition appear as the root of the file system:sudo chroot /mnt/debian
You might need to mount some essential directories before chrooting:
sudo mount --bind /dev /mnt/debian/dev sudo mount --bind /dev/pts /mnt/debian/dev/pts sudo mount --bind /proc /mnt/debian/proc sudo mount --bind /sys /mnt/debian/sys
-
Reset the Root Password: Now that you’re chrooted into your Debian system, you can reset the root password as you normally would:
passwd
Enter the new password twice when prompted.
-
Exit Chroot and Unmount: Exit the chroot environment:
exit
Unmount the partitions:
sudo umount /mnt/debian/dev/pts sudo umount /mnt/debian/dev sudo umount /mnt/debian/proc sudo umount /mnt/debian/sys sudo umount /mnt/debian
- Reboot: Reboot your system and remove the Live CD/USB. You should now be able to log in with the new root password.
2. Using systemd.unit=rescue.target
This method leverages systemd
, the system and service manager in Debian, to boot into rescue mode, which provides a root shell.
Steps:
- Restart and Access Grub: Restart your Debian 12 system and access the Grub menu as described in the original solution (hold Shift key).
- Edit Grub Entry: Press ‘e’ to edit the Grub entry.
-
Modify the Kernel Line: Find the line starting with
linux
and addsystemd.unit=rescue.target
to the end of the line. Similar to the original solution, but with a different parameter.linux ... systemd.unit=rescue.target
- Boot the System: Press Ctrl+X or F10 to boot the system.
- Access Root Shell: The system will boot into rescue mode, presenting you with a root shell. You might be prompted to press Enter to activate the console.
-
Remount Root Partition in Read-Write Mode: The root partition may be mounted in read-only mode. Remount it in read-write mode:
mount -o remount,rw /
-
Reset the Root Password: Use the
passwd
command to reset the root password:passwd
-
Reboot: Reboot the system:
reboot
You should now be able to log in with the new root password.
These alternative methods provide additional ways to Reset Linux Root Password on Debian 12 Bookworm, offering flexibility depending on your setup and available tools. Remember to choose the method that best suits your comfort level and technical expertise. Always back up your important data before attempting any system recovery procedures.