Did you forget your password on your Linux PC? Can’t get back in? Don’t worry! You can use the Ubuntu live disk to reset your password! In this guide, we’ll show you how to do it!
Creating a live disk
Before we can use the Ubuntu live disk to reset your password, we need to create the live disk. To make the live disk, start by heading over to Ubuntu.com/desktop. Once on the desktop page, select the “Download Ubuntu” button.
Upon selecting the “Download Ubuntu” button, you will be taken to the download page, where you’ll see two choices available for download. Look for “Ubuntu 20.10,” and select the green download button next to it to start the download of the Ubuntu 20.10 ISO file.
When the ISO file is done downloading to your PC, head over to Etcher.io, and plug in your favorite USB flash drive into the USB port. Then, download the latest version of Etcher to the computer you are creating your Ubuntu live disk on.
Note: the great thing about Etcher is that it is cross-platform! Even if you’re locked out of your Linux PC, you can still create your Ubuntu live disk on a Mac, Windows PC, or other Linux systems!
After downloading the latest release of Etcher on your computer, launch it. Then, follow the step-by-step instructions below.
Step 1: Locate the “Flash from file” button in the Etcher app, and select it with the mouse. Upon selecting this button, a pop-up window will appear. Use this window to browse for the Ubuntu 20.10 ISO file.
Step 2: Select the “Select target” button with the mouse. Then, use the menu to choose your USB flash drive.
Step 3: Select the “Flash!” button with the mouse to start the Ubuntu live disk creation process. It may take a couple of minutes to complete!
When the live disk is done flashing, reboot the PC you wish to reset the password of into its BIOS, and configure it to boot from USB to access the Ubuntu live disk.
Mounting Linux as a Chroot
The only way to change your password (if you are locked out) is with a Chroot. A Chroot allows the user to mount an operating system inside of a self-contained environment.
Accessing a Chroot isn’t easy if you’re new to Linux. You will need to understand a bit about file systems, including what is mounted were. However, we will break it down in as simple terms as we can!
To start, launch a terminal window in the live disk. Once the terminal window is open, transition the live disk to the root user using the sudo -s command.
After accessing the root user, run the lsblk command. This command will show every hard drive and partition connected to your Linux system.
From here, you must look through the lsblk output for your Linux hard drive partitions. In this example, we will be using
/dev/sda1 for the boot partition and
/dev/sda2 the root partition. Yours may differ.
Please read our in-depth tutorial on finding hard-drive information on Linux if you cannot figure out what partitions are. It will help you understand the lsblk output and help you find out what partitions are what.
Once you’ve figured out what partitions are, you can mount them to the /mnt directory in the Ubuntu live disk using the commands below.
/dev/sda2 are merely examples. Please change the
/dev/sda2 portions of the command below to reflect the partitions you need to mount.
First, we mount the root filesystem to the
/mnt directory. In this example, the root filesystem is on.
mount /dev/sd2 /mnt
After mounting the root file system to
/mnt on the Ubuntu live disk, we must mount
/dev/sda1, the boot partition to
/boot/efiIn this example, the Linux system we are working with has a dedicated EFI partition.
If you do not have a dedicated EFI partition, skip this step. Alternatively, if your EFI mount path is different (for example,
/boot instead of
/boot/efi), be sure to change it in the command below.
Note: the path in the mount command must start with
/mnt/ if you are to change it.
mount /dev/sda1 /mnt/boot/efi
Once all filesystems are mounted, mount the Chroot to your Ubuntu live disk using the following commands.
cd /mnt mount --bind /dev /mnt/dev mount --bind /dev/pts /mnt/dev/pts mount --bind /proc /mnt/proc mount --bind /sys /mnt/sys chroot /mnt
With all the above commands entered, you will have mounted your Linux system in a Chroot and have full command-line access to it.
Reset password with live disk
Once you connect to the Chroot in the Ubuntu live disk, you will instantly have access to your Linux PC’s root user account. Since you have root access, you can easily change the user account’s password, which you forgot.
To change the password, execute the passwd command followed by the username. For example, to reset the password of the “derrik” user, you’d do:
After entering the passwd command, the terminal prompt will ask you to set a new password. Do so. Then, reboot the computer, and the password will have been reset!
The post How to reset your Linux password with the Ubuntu live disk appeared first on AddictiveTips.