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!
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.
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.
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.
Step 4
Wait while your Ubuntu system goes into recovery mode.
Step 5
On Recovery Mode, select the Root “Drop to root shell prompt” option.
Step 6
In this step, press Enter to access the console screen.
Step 7
At the root command prompt, type mount -o rw, remount /, and press Enter.
root@sysnettechubuntu:~# mount -o rw, remount /
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
Step 9
Wait for a while and be patient while your Ubuntu OS is restarting.
Step 10
If GRUB appears in the menu after your system boots up, continue by selecting the Ubuntu option.
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:
- 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.
- 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
orlsblk
command to determine this partition. This command will list your available disks and partitions. - Once you identify the root partition (for example,
/dev/sda1
), mount it in a directory. For example, you can usesudo mkdir /mnt/ubuntu
orsudo mount /dev/sda1 /mnt/ubuntu
. - 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. - 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 thepasswd ubuntuuser
command to change the root password. - After changing the password, exit the chroot environment by typing the
exit
command and pressing the Enter key. Afterward, disconnect the root partition with thesudo 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)
- I forgot the root account password for my Ubuntu system. How can I reset it?
- Is there any other method to reset the password?
- What should I pay attention to when resetting the root password?
- What should I do after resetting my password?
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.
Thanks a lot, it helps!
You’re welcome! Thank you for your comment!
please, guide me step# 06 which is not open Command prompt I have tried many time. please guide thanks.