How to Reset Forgotten Root Password in Ubuntu

It’s a common scenario – you’re working on your Ubuntu system and suddenly realize you’ve forgotten the root password, which can be a frustrating experience, as the root account is essential for performing critical administrative tasks.

However, don’t worry, in this article, you will learn how to reset the forgotten root password on Ubuntu 24.04, Ubuntu 22.04, and Ubuntu 20.04 LTS.

Step 1: Access the GRUB Menu

Firstly, you need to either power on or reboot your Ubuntu system, and when the system is booting up, press the Shift or ESC key on your keyboard to bring up the GRUB menu, which provides various options for booting your system.

If you are running your system on VirtualBox, press the ‘SHIFT’ key on the keyboard to bring up the boot menu.

Ubuntu Grub Menu
Ubuntu Grub Menu

Step 2: Edit the GRUB Menu Options

Once you’re in the GRUB menu, use the arrow keys to navigate to the Ubuntu entry and press the 'e' key to edit the grub parameters.

Grub Boot Parameters
Grub Boot Parameters

Scroll down until you get to the line that begins with 'linux the entire line is highlighted below.

Find Grub Boot Parameter
Find the Grub Boot Parameter

Narrow down to a section that reads "ro quiet splash $vt_handoff".

Locate Grub Boot Parameter
Locate the Grub Boot Parameter

Replace "ro quiet splash $vt_handoff" with rw init=/bin/bash as shown. The aim is to set the root file system with read and write commands denoted by the rw prefix.

Enable Root Filesystem
Enable Root Filesystem

Thereafter, press ctrl + x or F10 to reboot your system.

Step 3: Remount the Root Filesystem

Your system will boot into a root shell screen as shown below. You can confirm that the root filesystem has read and write access rights by running the command.

# mount | grep -w /

The output in the screenshot below confirms read and write access rights denoted by rw.

Confirm Root Filesytem Permissions
Confirm Root Filesystem Permissions

Step 4: Reset the Root Password

With the root filesystem mounted in read-write mode, you can now reset the root password using the passwd command:

# passwd 

Provide a new password and confirm it. Thereafter, you will get a ‘password updated successfully’ notification.

Reset Root Password in Ubuntu
Reset Root Password in Ubuntu

After resetting the root password, it’s a good idea to remount the root filesystem in read-only mode to enhance system security.

mount -o remount,ro /

Finally, reboot your Ubuntu system to apply the changes and allow you to log in with the new root password

exec /sbin/init
OR
reboot

After the reboot, you should be able to log in as the root user using the new password you set.

Conclusion

Resetting the forgotten root password in Ubuntu is a straightforward process that can be completed in a few simple steps.

By accessing the GRUB menu, editing the boot options, and using the root shell to reset the password, you can regain full administrative access to your system.

Remember to choose a strong, secure password and remount the root filesystem in read-only mode for enhanced security. With this guide, you should be able to quickly and easily reset the root password on your Ubuntu system.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

25 Comments

Leave a Reply
  1. After the reboot step, the Acer laptop continues to slowly scroll : { 3765. etc nonstop with the first numbers increasing in value? Let it run all night and still the laptop is scrolling. Redid it all after shutting down and restarting, Followed the directions again, and once more it is doing the same thing.

    Any ideas? I thought it would finally come to an end – but it sure doesn’t look like it. How long should this part of the process continue? Days?

    Reply
  2. Thanks much for this article,

    I made the mistake of changing the username when installing the virtual machine, so that name was not included in sudoers and I didn’t have the root password. Reboot, reset root PW, visudo, and add the correct user (I use NOPASSWD:ALL since it’s a VM on a laptop just for utility) reboot again, and “all better now.” :-)

    Reply
  3. I have problems after pressing F10. The system boots and prompts “root@(none):/#” but I lost keyboard, so I can’t input anything at all.

    The system is up, if I plug/unplug the usb keyboard it’s detected on linux (ubuntu) and shows on the screen. The only thing I guess it may be related to the keyboard, it is a wireless one, so maybe, just maybe, it needs some additional drivers.

    I’ll try with a wired and tell you if it works.

    If any have a hint, it will be appreciated.

    Reply
        • My screen showing the password is updated successfully. But when I log in after reboot, the screen showing an incorrect password. And i am using 20.04 LTS Ubuntu

          Reply
          • Maybe you mistyped a character or two. Try the password reset again and write down what it is. Then when you try to log in, you know exactly what to type.

            Or you can start using a Password Manager. No matter what you type for a password, the PM will remember for you.

          • While changing the passwd use below commands,
            -> check the username
            ls /home
            -> now use this username(ubuntu) to change the passwd
            passwd ubuntu
            enter the new passwd.
            And follow the steps from this website to proceed next.

    • Hey Moses, if you are not in a virtualized environment – that is if you are running Ubuntu in a physical or bare metal system – then the grub menu should pop up without any difficulties.

      Reply
  4. I can’t reset my password in ubuntu18.04. I have like that “ro quiet splash acpi_osi= $vt_handoff“.

    Not the same with you. So I replace all like that ~

    From => ro quiet splash acpi_osi= $vt_handoff
    T0     => rw init=/bin/bash
    

    But is still does not work.
    I cannot understand why i have “acpi_osi= “.

    Reply
  5. Thank you for your article!

    It seems to me, there is a mistake after “To reset the root password execute the command.” The command “passwd” should be inserted in a string instead of “passed”.

    Reply
  6. “To reset the root password execute the command.

    # passed
    

    I think you mean “passwd” and not “passed“. Letters “w” and “e” are next to each other in the keyboard.

    Reply
  7. To reset the root password execute the command.

    # passed
    

    Don’t you mean:

    # passwd
    

    Finger check – the “e” and “w” keys are next to each other.

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.