How to Reset Forgotten Root Password in Ubuntu

Did you forget the root password for your Ubuntu operating system? Don’t worry; you don’t need to reinstall the operating system as a whole. In this article, I will guide you through the process of resetting the forgotten root password in the Ubuntu distribution.

First of all, you can change your account password in Recovery Mode on your Ubuntu system. In this way, you will be able to access your system without any problems. Let’s start!

Resetting Root Password in Ubuntu

How to Change Forgotten Root Password in Ubuntu

Let’s say you are using Ubuntu, one of the excellent Linux distributions, on your host PC. You haven’t logged in to your system for a long time, and you forgot the root password. In such matters, you do not need to worry much. You can easily reset your account with simple steps and without needing any additional software.

There is no need to reinstall your operating system because of a forgotten password. So, such a process will take both your time and energy. Because of that, you can reset passwords by following a few simple steps.

To reset your password, you must put your computer in Ubuntu Recovery Mode. You can access the Root Shell by restarting your PC to enter here. While this process takes about a minute, it may differ for other Linux distributions.

Now, follow the steps below to refresh your root password on your Linux system.

Resetting Root Password on Ubuntu PC

Password reset procedures are almost the same on other Linux distributions. However, I will show you this process in the Ubuntu system that we commonly use.

Step 1

You couldn’t remember your Ubuntu password when you turned on your computer. And in this case, you encountered the screen in the image below. This screen tells you that the password you entered or attempted is incorrect.

If you want to get to work immediately and reset your password, restart your Ubuntu PC.

As soon as your PC starts, enter the GRUB menu by pressing and holding the Shift key on the Boot screen.

Ubuntu Invalid Password Error

Step 2

In old or new versions of the Ubuntu distribution, you will see the GRUB menu, as shown in the image below. Now, press Enter on the “Advanced options for Ubuntu” option from the GRUB menu.

Advanced options for Ubuntu

Step 3

Then, press the Enter key on the “Ubuntu, with Linux 4.10.0-21-generic (recovery mode)” option. At this point, we will start Recovery Mode in the Linux distribution.

Ubuntu Recovery Mode

Step 4

Wait while your Ubuntu system goes into recovery mode.

Loading initial RamDisk

Step 5

On Recovery Mode, select the Root “Drop to root shell prompt” option.

Selecting the drop to root shell prompt

Step 6

In this step, press Enter to access the console screen.

Opening Shell Prompt

Step 7

At the root command prompt, type mount -o rw, remount /, and press Enter.

root@sysnettechubuntu:~# mount -o rw, remount /

Executing the mount -o rw, remount / command

Step 8

In this step, you need to type the username and the password you want to reset. For this reason, set a new password with the passwd (username) command on the relevant screen.

root@sysnettechubuntu:~# passwd (username)

Finally, reboot your Ubuntu computer using the sudo reboot command. After this process, you will now be able to log in to your system with your new password.

root@sysnettechubuntu:~# sudo reboot

Resetting the Ubuntu Root Password and Rebooting the PC

Step 9

Wait for a while and be patient while your Ubuntu OS is restarting.

Ubuntu Restart Screen

Step 10

If GRUB appears in the menu after your system boots up, continue by selecting the Ubuntu option.

Ubuntu GRUB Menu

Changing Password Using Chroot Method in Ubuntu System

Don’t worry if the above method did not work to reset the root or user account password in Ubuntu. If the Recovery Mode method does not work, there is an alternative method to achieve this. This approach is to boot into a live environment. So, you can mount the root partition using a live CD or USB. Immediately afterward, you can use chroot on the mounted system.

To reset the password with a CD & USB, follow these:

  1. Boot your Ubuntu computer from Live CD/USB. In fact, this process will only allow you to use an extra system without installing the system.
  2. It would be best if you mounted the Ubuntu root, that is, the root partition. To do this, open a terminal in the live environment. Then, identify the root partition of your installed Ubuntu system. Use the fdisk or lsblk command to determine this partition. This command will list your available disks and partitions.
  3. Once you identify the root partition (for example, /dev/sda1), mount it in a directory. For example, you can use sudo mkdir /mnt/ubuntu or sudo mount /dev/sda1 /mnt/ubuntu.
  4. Now, you will use the chroot method for the system you mounted. After connecting the root partition, you will run commands as if you were working on your installed Ubuntu system. At this stage, execute the sudo chroot /mnt/ubuntu command.
  5. After entering the chroot environment, you need to use the passwd command. For example, you planned to change the password of user ubuntuuser. In this case, you will use the passwd ubuntuuser command to change the root password.
  6. After changing the password, exit the chroot environment by typing the exit command and pressing the Enter key. Afterward, disconnect the root partition with the sudo umount /mnt/ubuntu command.

Finally, restart your computer and remove the Live CD/USB. You should now be able to log in to your Ubuntu system using the newly set root password. In short, the Chroot process helps us when Recovery Mode does not work.

Video Tutorial

If you forgot your Ubuntu Root password, watch our video tutorial below to understand how to reset it. If you find the video helpful, you can subscribe to our YouTube channel to show your support!

Frequently Asked Questions (FAQ)

  1. I forgot the root account password for my Ubuntu system. How can I reset it?
You can first use recovery mode to reset your Ubuntu password. To do this, hold down the Shift key while rebooting your PC. Thanks to this key, you will be able to open the GRUB boot menu. Then, pick “advanced options” and select the recovery mode option. After entering recovery mode, enter the root area. On this screen, you can use the “passwd” command to change the root password.
  1. Is there any other method to reset the password?
Yes, if you cannot access recovery mode, you can also use a live CD & USB to reset the password. However, after preparing your media, boot your PC with one of them. Then, mount the root partition. Here, you can chroot it and change your password.
  1. What should I pay attention to when resetting the root password?
It would be best if you were careful for security reasons when changing your account password. You must have the necessary authority to reset the password. Also, choose a more memorable password and write it down in your secure area. This way, you can easily access your forgotten passwords in the future.
  1. What should I do after resetting my password?
After the Ubuntu password change process, verify that your account has the appropriate privileges. You may also consider creating additional user accounts for possible errors.

Conclusion

I want to summarize: we can easily reset the Root password we forgot in the Ubuntu operating system. Thanks to this process, there is no need to reinstall our OS.

By following the steps I explained in this guide, you can reaccess your Ubuntu system’s account without any problems.

3 Comments

Add a Comment

Your email address will not be published. Required fields are marked *