How to change the root password in Ubuntu

Ubuntu is an operating system designed for beginners and is therefore easy to use. However, this ease of use is not only used by novices, but also by professionals who use it. One of the easiest things we can do is to change the root password in Ubuntu. To achieve this, we can do it from the grub as a form of recovery or from the terminal with our session. Let’s go for it.

Change the root user password in Ubuntu

By default, the root user is disabled in Ubuntu. But this doesn’t mean that we can’t change the password. However, there is one thing to keep in mind and that is that in Linux only the root user can change the root password.

So if you can access the Linux terminal in a normal session, you can then open a terminal and run

sudo -i

You will be prompted for your password, but by doing so, you will be able to log in as root.

Now yes, you can change the root password by running

passwd root

You will be prompted to enter it twice, and it will be changed.

Recover the root user password

The above procedure is valid as long as the user has access to sudo but this is probably not the case. What to do? Well, we can do it from GRUB.

If Ubuntu is the only operating system installed on your computer, then we have to do a trick first, and that is to show the grub.

To achieve this, edit the GRUB configuration file.

sudo vi /etc/default/grub

And find the following line

GRUB_TIMEOUT_STYLE=hidden

And replace it with the following

GRUB_TIMEOUT_STYLE=menu

Save the changes and to apply them you have to run

sudo update-grub

Then, reboot the computer.

When you see the grub, select the second option, which is Recovery Mode.

Ubuntu recovery mode
Ubuntu recovery mode

Thereafter, request a console as root user by selecting the root option.

Root shell prompt to change the root password in Ubuntu
Root shell prompt to change the root password in Ubuntu

Grant write permissions to the file system

mount -o rw,remount /

Next, change the root password

passwd root

Finally, synchronize the changes and reboot the system.

sync
reboot

That’s it. The root password has been changed.

Conclusion

Changing the root password is something we can do through grub or through the terminal in our normal session. Try it now in Linux Mint.

I hope you liked this post and help us to grow by sharing it.

Share This:

Leave a Comment

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