Skip to content

Instantly share code, notes, and snippets.

@BruceWind
Last active January 20, 2024 08:39
Show Gist options
  • Save BruceWind/49e03480d87bf1530211a4d58284385e to your computer and use it in GitHub Desktop.
Save BruceWind/49e03480d87bf1530211a4d58284385e to your computer and use it in GitHub Desktop.
reset Ubuntu password with live USB drive.

To make this method work, we need to have bootable media created from the Ubuntu ISO. Download the Ubuntu ISO. In my case, I'm running Ubuntu 20.04.1 LTS.

Create a bootable USB flash drive. Refer to the instructions on how to create a bootable USB drive.

Boot into the Ubuntu bootable media. When prompted, select "Try Ubuntu". This will start the Ubuntu live session.

Once in the live session, launch the terminal.

We need to identify the root file system partition. The following command will list all the partitions in the system. The important part of the output is the last section, which contains a short partition table.

$ sudo fdisk -l

From the table, we determine that the boot partition is /dev/sda5. Now, install it by running this command.

$ sudo mount /dev/sda5 /mnt

Run the next command to cross-install the contents from the live installation.

$ for d in dev sys run proc; do sudo mount --bind /$d /mnt/$d; done

Now, use chroot to become the root of the system.

$ sudo chroot /mnt

Finally, run the passwd command to change the root password.

$ passwd

Once this process is complete, restart the system.

Please note that the above steps assume some prior knowledge of using the terminal and working with Ubuntu systems.

This article is copied from https://cn.linux-console.net/?p=16598

I had tested with this method to reset password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment