You are on page 1of 4

How to Reset the Root Password in Linux

In Linux, regular users and superusers are allowed to access services via password
authentication. In the case a regular user can’t remember his/her password, a
superuser can reset the password of a regular user right from the terminal. However,
what if the superuser (or root user) loses his/her password? They will have to
recover the lost password prior to booting into the login screen. This allows any
malicious user with physical access to your Linux host to gain complete ownership.
This article takes a look at how to recover a lost root password in Linux using two
different methods.

Note: the method of resetting a root password is similar for most distros. Here we
demonstrate the process using Ubuntu. We are also using “root password”
throughout the tutorial for simplicity, but it can be interpreted interchangeably as the
superuser password.

1. Reset Lost Linux Root Password from the Grub Menu


1. First and foremost, to recover a lost root password, we need to restart the Linux
host, assuming you forgot the password for root.

2. Once the GRUB page appears, quickly select the “*Advanced options for
GNU/Linux” option by pressing the down arrow key and Enter button.
3. Now press e to edit the commands.

You need to modify it or change it from “read-only” mode to “read-write” mode. Find
the line beginning with “Linux.” Look for ro and change it to rw . Add init=/bin/bash at
the end of the line.
4. Press F10 . This will display a screen with a prompt.

5. Mount your root file system in read-write mode:


mount -n -o remount,rw /

6. You can now reset your lost root password by using the following command:

passwd root

Once you are done, type:

exec /sbin/init

This will exit the prompt and reboot the computer.

You might also like