Linux Guide/Reset a forgotten root password

How to reset forgotten root password in a GNU/Linux distribution with GRUB?

If this is a laptop or a desktop which you have next to you then follow these steps.

1. Shut down the device.

2. Start it again. When you see GRUB menu, press the ‘e’ key on the keyboard before the system starts booting.

3. In the GRUB boot options, scroll down and locate the line that begins with ‘linux’. In this line move the cursor to the end, right after ‘ro quiet’. Delete everything after that. Change 'ro' to 'rw'. Append the parameter init=/bin/bash

4. Press Ctrl+x, or F10, to boot.

5. You will see a root prompt.


Remount the filesystem in read/write mode:

:# mount -no remount,rw /

6. Set the password of any user(s).

:# passwd joe

7. Reboot with the command "reboot -f".

7a. or Reboot with the command "exec /sbin/init"

The new password should work now.