How to reset Linux root password via Live CD

If it is not possible to use the GRUB bootloader as I described in this article – How to reset the root password in Linux via GRUB, you will have to run a Live CD, for example Ubuntu Desktop, at startup select “Try Ubuntu …” instead of installing, and then it will start.
How to make bootable flash drives I described here – How to create a bootable flash drive

After starting the system, let’s look at which disk partition the Linux installed by the command (the commands must be run from the root user, therefore, in Ubuntu, the sudo command is used for this at the beginning):

sudo fdisk -l

Create a directory and mount our partition into it (in my case, it is /dev/sda3):

sudo mkdir /media/test
sudo mount /dev/sda3 /media/test

If the drive is mapped to LVM, see my article:
Solution for the error “mount: unknown filesystem type LVM2_member”

Change the root in the mounted partition

sudo chroot /media/test

If an error occurs:

chroot: failed to run command ‘/bin/bash’: No such file or directory

then you mounted something wrong, maybe swap or some other partition.

Change password:

passwd

Restart the system:

reboot

Leave a comment

Leave a Reply