How To: Reset forgotten root password
DISCLAIMER -- I do not take any responsibility for your actions if you go and try this on your friends machine!!
----------For Advanced Users only---------
To Protect Grub & restrict access to single user mode, assign a password to grub
Edit grub.conf @ #vi /etc/grub.conf
After Timeout entry add a new entry as -
password=<grub password>
Save & exit
Next time you reboot grub will not allow you to use 'e' or 'a' options. To go to single user mode press 'p' enter password and then use 'e' or 'a' as the process on top.
P.S - Tested on RHEL 5.1
- Reboot the system and when lilo/grub boot loader get to the point where you select the various installed kernels on the system, type the letter "a" for "append".
- You will get a prompt like this to add boot options to the boot string found in your lilo/grub conf file:
grub append> ro root=LABEL=/
- Append "init=/bin/bash" to it to look like this.
grub append> ro root=LABEL=/ init=/bin/bash
This tells the kernel to drop to a root prompt bash shell instead of starting the "/sbin/init" process. - The root filesystem is currently mounted read only which needs to be changed to read/write prior to resetting the password.
# mount -o remount,rw /
- Now that the file-system is remounted read-write, go ahead and type `passwd` to change the root password.
# passwd
- Since "init" isn't running to safely take down the system, remount the system to read only prior to shutting down the system.
# mount -o remount,ro /
- You can now safely press on the power button to shutdown the sytem.
----------For Advanced Users only---------
To Protect Grub & restrict access to single user mode, assign a password to grub
Edit grub.conf @ #vi /etc/grub.conf
After Timeout entry add a new entry as -
password=<grub password>
Save & exit
Next time you reboot grub will not allow you to use 'e' or 'a' options. To go to single user mode press 'p' enter password and then use 'e' or 'a' as the process on top.
P.S - Tested on RHEL 5.1
Comments