How to Reset the root Password

Setting up a root password is one of the steps when installing Fedora. If you forget, or lose, the root password, there are two common methods to reset it:

  • In Rescue Mode

  • Using a Fedora Live Media (USB/DVD/CD)

How to reset the root password in Rescue Mode

Changing passwords as root does not prompt for the old password.

While booting the system the GRUB2 menu will be displayed. To boot the system into rescue mode using bash follow these steps:

  1. Use the arrow keys to select the boot entry you want to edit

  2. Press e to edit that entry

  3. Use the arrow keys to go to the line that starts with linux, linux16, or linuxefi

  4. Go the the end of that line, add a space then type rw init=/bin/bash. If your disk is encrypted, you may need to add plymouth.enable=0

  5. Press Ctrl-x or F10 to boot that entry

  6. Run the command:

    passwd

    It will prompt you to enter the new root password twice.

  7. Restore the SELinux context and permissions with:

    touch /.autorelabel

    If you do not restore the SELinux permissions, the boot process may fail. You may have to do a hard-reboot and start back at step 1.

  8. Reboot the machine with:

    /sbin/reboot -f

The system may take a while to boot as SELinux will be relabeling its permissions on the filesystem. If you see the Plymouth boot screen you can press the ESC key on your keyboard to view the SELinux progress. Once it is complete, your system is ready and your root password has been successfully changed.

How to reset the root password with a Fedora Live Media

To download and create a live USB of Fedora Workstation, follow the instructions on the Fedora USB Live Media Quick Doc.

  1. Boot the Live installation media and choose Try Fedora

  2. From the desktop, open a terminal and switch to root using su (it won’t ask for a password)

  3. To view your hard drive device nodes, in the terminal type: df -H. For this example we will use /dev/sda1 for the /boot partition and /dev/sda2 for the root / partition.

    If you are using LVM partitions, type: sudo lvscan and note the /dev path of your root partition. For this example we will use /dev/fedora/root.

  4. Create a directory for the mount point (use the -p option to create subdirectories):

    mkdir -p /mnt/sysimage/boot
  5. Mount the / (root) partition (be sure to use the actual device node or LVM path of your root / partition):

    To mount root on a standard partition scheme enter:

    mount /dev/sda2 /mnt/sysimage

    To mount root on an LVM partition scheme enter:

    mount /dev/fedora/root /mnt/sysimage
  6. Continue the process by mounting /boot, proc, /dev, and /run with:

    mount /dev/sda1 /mnt/sysimage/boot
    
    mount -t proc none /mnt/sysimage/proc
    
    mount -o bind /dev /mnt/sysimage/dev
    
    mount -o bind /run /mnt/sysimage/run
  7. chroot to the mounted root partition with:

    chroot /mnt/sysimage /bin/bash
  8. Change the root password:

    passwd
  9. Exit out of chroot with:

    exit

    and exit out of the terminal.

  10. Reboot your system and boot from the hard drive.

Congratulations, your root password has been successfully changed.

Additional Troubleshooting

  1. If you cannot enter rescue mode because you forgot the Firmware/BIOS password here are some options:

    1. Refer to your computer’s documentation for instructions on resetting the Firmware/BIOS password in CMOS memory.

    2. Temporarily move the system hard disk to another machine, and follow the procedures above to reset the root password.

  2. If you have set a password for your boot loader, refer to Creating and Using a Live Installation Image.

  3. If you want to reset the boot loader password, refer to the instructions on how to Reset the Bootloader Password.