We have already discussed how to reset root user password from single user mode in Fedora. If that method doesn't work for some reason, you can recover the root password using Fedora Live CD/USB. In this step-by-step tutorial, we will learn how to change the forgotten password of your root user from Fedora live CD or USB medium.
Step 1 - Create a Fedora Live USB
Step 2 - Boot from the Fedora Live USB
Insert the Live USB into your system and boot from it. You might need to change your BIOS/UEFI settings to boot from the USB drive.
Step 3 - Identify and Mount your System's Root Partition
Once the Live environment is up and running, open a terminal. You need to identify your system's root partition.
You can use commands like
fdisk -l to list all partitions and identify your Fedora root partition (usually labeled with the filesystem type like ext4).
In the Fedora live environment, the root partition of the live system is different from the root partition of an installed system on the hard drive.
To find and check the root partition of your installed system, you need to do the following:
1. List all available partitions
First, identify the partitions on your hard drive. You can use the
lsblk command for this. Open a terminal and type:
This command lists all block devices (like hard drives, partitions, etc.). Look for the partitions under your main hard drive. They are typically named like
sda2, etc., under a device named
sda or similar.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS loop0 7:0 0 1.9G 1 loop loop1 7:1 0 7.6G 1 loop ├─live-rw 253:0 0 7.6G 0 dm / └─live-base 253:1 0 7.6G 1 dm loop2 7:2 0 32G 0 loop └─live-rw 253:0 0 7.6G 0 dm / sda 8:0 0 50G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 1G 0 part └─sda3 8:3 0 49G 0 part sr0 11:0 1 2G 0 rom /run/initramfs/live zram0 252:0 0 7.7G 0 disk [SWAP]
2. Mount the root partition
Once you identify which partition might be your root partition (typically the largest one, or known from previous experience), you need to mount it to inspect it.
In my case, the root partition is
/dev/sda3. You can mount it by creating a new directory and using the
$ sudo mkdir /mnt/myroot $ sudo mount /dev/sda3 /mnt/myroot
/dev/sda3 with the actual partition you wish to inspect.
3. Check the mounted partition
Now, you can check the details of this partition by pointing
df to the mount point:
$ df -h /mnt/myroot
This will show you the disk usage information for the partition you think is the root of your installed system.
4. Inspect the contents
You can also
/mnt/myroot and use
ls to look at the contents of the partition to verify if it's indeed the root partition of your installed system.
$ cd /mnt/myroot $ ls
You should see root filesystem directories like
usr, and so on, if it's indeed the root partition.
Be cautious when working with mount commands and ensure you are mounting the correct partition to avoid any data loss.
Step 4 - Chroot into Your System
Change root into your system:
$ sudo chroot /mnt/myroot/root
Step 5 - Reset Fedora Root User Password
Now reset the root password with command:
Enter the new password and confirm it.
Step 6 - Unmount and Reboot
Exit the chroot environment and unmount the partition:
$ sudo umount /mnt/myroot
Remove the Live USB and reboot your system.
Step 7 - Boot into Your Fedora System
Now boot into your Fedora system normally. Click on the Root user.
Use the new root password to log in.
If you can able to log in with the new root password, Congratulations! You have successfully reset the root user password in Fedora Linux.
This method is a bit more involved but it bypasses the need to entering into single-user mode. It's a common approach used not only for resetting passwords but also for various system recovery tasks.
As always, proceed with caution and ensure you have backups of important data. If you are not comfortable with these steps, it might be safer to get help from someone experienced in Linux system administration.