This is a situation one can easily end-up if the option ‘autologin’ is turned on. Not typing your password for a while leads to forgetting it. This is how to reset a user’s password on a Fedora 20 and Ubuntu 14.04 system using a LiveCD. There are a few other methods to do this but they have a high rate of failure. Moreover, this is a tested method so it’s pretty obvious it works.

To reset a password on these two systems, I’ve used an Ubuntu LiveCD, but you can use about any other live distribution CD as long as it’s the same architecture. Using a 32bit livecd on a 64bit installed system just won’t work.

Resetting a user’s password on Fedora 20

First, boot the system from the LiveCD. Once you got the desktop loaded, open a terminal and run the following commands.

Because Fedora has a more complicated filesystem management, it’s a bit more tricky to find the root partition of the system. This is the most common situation if you’ve chosen to ‘automatically setup partitions’ while installing Fedora.

Make sure the lvm2 package is installed

sudo dpkg -s lvm2
Package: lvm2
Status: install ok installed

Ubuntu has it installed by default but if you’re using another distribution liveCD, just use its package manager to install it.

sudo vgscan
Reading all physical volumes. This may take a while...
Found volume group "fedora" using metadata type lvm2

Goot, it found the ‘fedora’ volume group. If your has a different name, use it accordingly.

sudo lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
home fedora -wi------ 111.38g
root fedora -wi------ 50.00g
swap fedora -wi------ 3.89g

We’ll be using the ‘root’ logical volume.

sudo vgchange -ay fedora
3 logical volume(s) in volume group "fedora" now active

cd ~
mkdir fedora
sudo mount /dev/fedora/root fedora/
ls fedora/
bin dev home lib64 media opt root sbin sys usr
boot etc lib lost+found mnt proc run srv tmp var

Now, to run the passwd command on that root filesystem, type:

sudo chroot fedora/

You should get a bash with a # at its end. Type there this command, where ‘username’ is the user you want to change the password for. For user ‘root’, just type ‘passwd’ .

passwd username
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Now type exit and sudo reboot. That’s it!

Resetting a user’s password on Ubuntu 14.04

First, boot the system from the LiveCD. Once you got the desktop loaded, open a terminal and run the following commands.

We now need to find the partition where your Ubuntu is installed. If you have only one operating system installed, finding it will be easy as there is only one option to choose from. For more Linux operating systems installed will be a bit tricky:

sudo fdisk -l /dev/sda
Disk /dev/sda: 36.4 GB, 36420075008 bytes
255 heads, 63 sectors/track, 4427 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 63 1028159 514048+ 83 Linux
/dev/sda2 1028160 15358139 7164990 83 Linux
/dev/sda3 63 71119754 35559846 7e Unknown
/dev/sda4 15566985 71119754 27776385 5 Extended
/dev/sda5 15567048 17667277 1050115 82 Linux swap
/dev/sda6 17667341 17669388 1024 7f Unknown
/dev/sda7 17671563 71119754 26724096 83 Linux

We are only interested in the devices with System Linux so that should narrow it down. Let’s say the Ubuntu installation you want to change the password for is installed on /dev/sda1.

cd ~
mkdir ubuntu/
sudo mount /dev/sda1 ubuntu/

Take a look around the partition using cd ubuntu; ls etc, or use the file manager. If this isn’t the Ubuntu installation you’re looking for, umount the device and mount the following.:

cd ~
sudo umount ubuntu/
sudo mount /dev/sda2 ubuntu/

And so on, until you get it right. Then, run this:

cd ~
sudo chroot ubuntu/

When the superuser bash (#) shows up, change the password with:

passwd username

Where username is the user you want to change the password to. For user ‘root’, just run ‘passwd’ without anything after it. When you’re done, type exit and reboot the computer. That’s it.

Resetting a lost password in Fedora 20 and Ubuntu 14.04
Tagged on: