Linux Guide/Reset a forgotten root password

From Wikibooks, open books for an open world
Jump to navigation Jump to search

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’. Delete everything on that line. 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.


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 with code "Reboot -f".

8a. or Reboot with code "exec /sbin/init"

The new password should work now.