Steps to Reset your Root Password in Debian 12 bookworm Linux

Handling multiple Linux systems or once in a while, there might be chances of forgetting the root user password. If so, here is the article to reset the root password on Debian 12 Linux (bookworm) servers or desktops.   

Debian is quite popular among server users as compared to Desktop. And we all know how important is for a Server OS to be stable and maintained for the long term. That is the reason why we should give a chance to Debian Linux. It is already powering thousands of hosting and other servers around the globe.

However, what happens when you are not able to log in to your Debian server because you are in a situation where either you have forgotten or misplaced the root user account password? And without having the access to superuser you won’t be able to install most of the applications that required admin privileges.

Apart from that, losing access to the root account will also limit your access to perform system-critical tasks. Even modifying systems files and configuration will be limited. Well, I can understand the pain, and that’s why here in this article we will discuss the process of resetting the root password in Debian 12 Linux. So, that you can get back full control over your server or desktop.

In the resetting root password process, the user cannot recover the old password instead will be replaced or changed by the new one without knowing the old one.

A step-by-step guide to resetting the forgotten root password of Debian 12.

1. Restart Debian 12 to have the Grub menu

To reset the root password, first of all, we restart our Debian 12 system or virtual machine we are using. Soon as the system restarted, it will show you the Grub menu for a few seconds to select the advanced option. Press any arrow key to stop the system from further processing.

2. Modify GRUB to Reset the root password

To open the Grub Menu editing screen, press the ‘e‘ key on your keyboard. This will drop you on an editor, don’t touch or delete anything, just from here move to the next step.

Access Linux Grub Menu

3. Add rw init=/bin/bash to Debian 12’s Grub

You will see a couple of lines that tell the system how to boot itself, so don’t edit anything arbitrarily. Instead, use the arrow keys and move to the end of the line starting with “Linux“. At the end of this line after ro quiet type –

rw init=/bin/bash

To have an idea you can see the given screenshot. Once you are confirmed that the added line is exactly, what we have shown here in the screenshot. After that boot your system with these added changes by pressing F10.

Edit Grub Menu Debian 12

You might like to know what is “rw init=/bin/bash” is that we have added. It is a Linux boot option that tells the system to run the and drop us in a shell (“/bin/bash”) with read and write permissions (“rw” or read-write) to the file system. Whereas, the “init” in the command is the first process that runs when the operating system is booted, and it is responsible for starting and managing other processes.

4. Check file system permission

After following the previous step you will see yourself in the shell to execute the commands. Let’s first check whether we have read and write access to the Debian 12 file system or not. Because without that we cannot change the root password.

mount | grep -w /

The output must be with rw,realtime. It reflects that we have real-time- read-and-write access to the file system.

Check file system read and write access

 5. Reset the Debian 12 Root password

Finally, we will run the commands that will allow us to change the current forgotten root password of our Debian 12 Bookworm server or desktop system.

passwd

The command will ask you to type the password you want to set twice.

Debian 12 root password reset sucessfully

(optional)

Well, if you want to change some other existing user account password apart from the root user then that can be done from here as well.

Simply type “passwd” command with the username. For example, if my non-root user account name is h2s, then to reset its password we will use:

passwd h2s

7. Restart the system and login as root

Well, guys, we have successfully changed our current root Debian 12 Linux password without knowing the old one. Let’s now restart the system properly. For that execute the given command on your terminal.

exec /sbin/init

Once the restart is done, you will see yourself on the Login screen of Debian 12 Bookworm. Here you can use the root user and the password you have changed for it.

Debian 11 users can see this linked article to reset their passwords.

FAQ

How do I find my root password in Linux?

We cannot read or find the root password because it is saved in an encrypted format. The only way to recover your root user access is by resetting the password manually.

How to log in without a root password Linux, if I have sudo access?

Those who have a user account with sudo access can switch to the root user without entering its password. For that, you have to use the command: sudo su or sudo su -

How to change the root password in Linux?

If you already have the access to sudo or root user then to change the password of the root you can run – sudo passwd root

Other Articles:

5 thoughts on “Steps to Reset your Root Password in Debian 12 bookworm Linux”

  1. Can you help me get my login ?
    I have been using automatic login for a longtime and have forgotten what it is.
    I know my password and am currently in my Linux Q4OS system with full access.

    Thanks

    Reply
  2. Dead in the water after step 3 on this one. ‘cannot set terminal process group…, no job control in this shell…, root@(none):/#’ and that’s it. Can’t use keyboard after this.

    Reply
  3. I got similar situation, after a few times of login in and shut down Debian 12 does not accept the password, I followed the steps but the grub does not recognise : “rw” or “sudo” commands ?

    Reply
  4. Thanks, I was able to log back in.

    I have a question though: isn’t it like a HUGE security issue?
    It means that virtually anybody that as access to my computer can log into it with extreme ease!

    Is there a security step I do not see?

    Reply
    • Well, if anybody has physical access to your computer then it can, however, remotely, a user will not have grub access. Moreover, for better security one can fully encrypt the disk or use the BIOS Password.

      Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.