14 C
Jaipur
Thursday, December 3, 2020

How to Reset Forgotten Root Password in Ubuntu? – Linux Hint

Must read

How to Install ELK on Ubuntu 20.04

The ELK stack is known as Elastic Stack is a collection of three open-source software i.e. Elasticsearch, Kibana, and Logstash. The ELK stack is...

JD: JD.com, SF, Carlyle among bidders for CJ Group’s $1 billion China logistics business: Sources – Latest News

Chinese online retailer JD.com , delivery company SF Group and Carlyle are bidding for South Korean conglomerate CJ Group's China logistics business in a...

Excitel announces new broadband plans, offers double speed at Rs 50 extra

Internet service provider Excitel has announced new fibre broadband plans and offer to double the speed of an existing plan at an additional cost...

How to use Instagram’s new Live Rooms feature

Facebook-owned photo-sharing app Instagram has rolled out a new feature — Live Rooms — for creators in India to go...

In any UNIX or Linux system, the root account is the top in the hierarchy. It holds the utmost power over the system. For any system change, the root has to grant permission. The root user can also override any user’s permission and read or write data. Because the root account holds so much power, it is important to protect it from unwanted access.In the case of Ubuntu, the root account is disabled by default. However, you can still perform system changes. To do so, you need to know the root password. The problem arises when you have forgotten the root password.

Check out how to reset the forgotten root password in Ubuntu.

Reset forgotten root password

Although it is difficult, it is still possible to reset the forgotten root password in Ubuntu. There are a couple of methods to do so. In short, the process is to get access to the root shell and change the password from there.

Method 1: Root shell from boot

When you are booting into Ubuntu, press, and hold Shift. This should open up the GRUB menu. In case there is multi-boot configured, there is probably no need to press the Shift key.


Select “Ubuntu” and press “e”. This will open up the grub parameters to edit.


Now, use the arrow keys and scroll down to the line that starts with “linux /boot/vmlinuz”.


From that line, replace “ro quiet splash $vt_handoff” with “rw init=/bin/bash”.


Press “Ctrl + X” or F10. This will reboot the system with the tweaks we just made. It will start the system and directly land you on the root shell. It is just a one-time thing, so next time the system boots, it will boot normally into the operating system.

Run the following command to confirm if the root filesystem mounted successfully.


Now, run the passwd command to change the root password.


Once the password is changed, you will see the success message.

The task is finished. Run the next command to reboot the system.

Method 2: Change password from Ubuntu live session

For this method to work, we need to have bootable media made from Ubuntu ISO. Download Ubuntu ISO. In my case, I’m running Ubuntu 20.04.1 LTS.


Make a bootable USB flash drive. Check out how to make a bootable USB drive.

Boot into the Ubuntu bootable media. When prompted, select “Try Ubuntu”. This will start the Ubuntu live session.


Once you are in the live session, fire up a terminal.

We need to identify the root filesystem partition. The following command will list all the partitions in the system. The key point of the output is the last section, where there is a short table of partitions.



From the table, we have determined that the boot partition is /dev/sda5. Now, mount it by running this command.

 $ sudo mount /dev/sda5 /mnt


Run the next command to cross-mount things from the live install.

 $ for d in dev sys run proc; do sudo mount –bind /$d /mnt/$d; done


Now, become the root of the system using chroot.

Finally, run the passwd command to change the root password.


Once the process is finished, reboot the system.

Final thoughts

As demonstrated, there is no need to fear when you have forgotten the root password in Ubuntu. Here, two methods are demonstrated. Follow the one that you feel comfortable with.

Now, these methods also open up the question of security. In case there is someone else having physical access to the computer. These methods could be used against you. To prevent this, you should configure a password to access the BIOS and boot menu. All modern computers have this feature built-in. However, this is a password that you MUST NOT FORGET.

Happy computing!

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to Install ELK on Ubuntu 20.04

The ELK stack is known as Elastic Stack is a collection of three open-source software i.e. Elasticsearch, Kibana, and Logstash. The ELK stack is...

JD: JD.com, SF, Carlyle among bidders for CJ Group’s $1 billion China logistics business: Sources – Latest News

Chinese online retailer JD.com , delivery company SF Group and Carlyle are bidding for South Korean conglomerate CJ Group's China logistics business in a...

Excitel announces new broadband plans, offers double speed at Rs 50 extra

Internet service provider Excitel has announced new fibre broadband plans and offer to double the speed of an existing plan at an additional cost...

How to use Instagram’s new Live Rooms feature

Facebook-owned photo-sharing app Instagram has rolled out a new feature — Live Rooms — for creators in India to go...

This is how Samsung’s next Galaxy Buds may look like

Just last week, it was reported that Samsung may not launch a bean-shaped wireless earbuds next year — along with the Galaxy...