How to recover root password when grub is lock

Boot into recovery mode from the install CD/DVD or Live CD.
From there you can access the terminal and mount the device containing /etc (usually /dev/hda1).
Edit the shadow file and just remove the encryption string for the root account.

Example:
From root:$1$aB7mx0Licb$CTbs2RQrfPHkz5Vna0.fnz8H68tB.:10852:0:99999:7:::
To root::10852:0:99999:7:::

Then just reboot and login as root.
When asked for a password, just hit enter. And then use passwd to change password.

How can i access terminal through live cd

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.