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 of this line, after ‘ro quiet’. Append the parameter init=/bin/bash

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

5. You will see a root prompt.

:#

Type "mount -n -o remount,rw /":

:# mount -n -o remount,rw /

This will mount the system as read and write (instead of the read-only, which is the default.)

6. Set the password of any user(s) whom it is forgotten for.

:# passwd joe

7. Press Ctrl+D or Ctrl+Alt+Del to exit.

8. Reboot.

The new password should work now.