How to recover root password when grub is lock

Dani AI

Generated

As pointed out, booting a live/rescue medium is the correct way to bypass a GRUB password. To answer : when you boot a live CD/USB you either get a live desktop (choose "Try"/"Rescue" or similar) or you land at a shell prompt — in a live desktop open a terminal from the application menu or press Ctrl+Alt+T. Once you have a terminal, use a chroot workflow to reset root safely rather than editing /etc/shadow by hand.

Typical safe sequence (replace device names with the ones on your system):

# discover the root device
lsblk -f

# mount the root filesystem
sudo mkdir /mnt/root
sudo mount /dev/sdXY /mnt/root

# (LVM) if you see LVM volumes:
sudo pvscan; sudo vgscan; sudo vgchange -ay
sudo mount /dev/mapper/<vgname>-<lvname> /mnt/root

# (LUKS) you must open the encrypted device first:
sudo cryptsetup open /dev/sdXY rootcrypt
sudo mount /dev/mapper/rootcrypt /mnt/root

# bind system dirs and chroot
for d in dev proc sys run; do sudo mount --bind /$d /mnt/root/$d; done
sudo chroot /mnt/root
passwd root
exit

# cleanup and reboot
sudo umount -R /mnt/root
sudo reboot

Notes and cautions: if the root filesystem is LUKS-encrypted you cannot reset the root password without the LUKS passphrase. If the distro disables root (Ubuntu-style), set a password for an admin user or add sudo rights inside the chroot. Be careful with device names — mounting the wrong disk can corrupt data. Only perform these steps on machines you own or are authorized to administer.

Recommended Answers

All 2 Replies

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.