- How to Reset the root Password
- How to reset the root password in Rescue Mode
- How to reset the root password with a Fedora Live Media
- Additional Troubleshooting
- How to Reset a Forgotten Root Password in Fedora
- How to Reset Forgotten or Lost Root Password in Fedora
- Edit the Fedora GRUB Settings
- Mounting the Fedora Filesystem
- Set Forgotten Root Password in Fedora
- Set SELinux Context on Shadow File
- Сброс пароля fedora linux
How to Reset the root Password
A root password may be set up while installing Fedora Linux, although it is now suggested to leave the root account locked and use sudo . This article describes how to proceed if you have used a root password, but for some reason you can no longer access it.
There are two common methods to reset the root password if it is forgotten or lost.
How to reset the root password in Rescue Mode
Changing passwords as root will 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:
- Select the boot entry you wish to edit with the arrow keys.
- Select the entry you with to edit by pressing e.
- Use the arrow keys to go to select the line beginning with linux , linux16 , or linuxefi .
- Go the the end of that line and include a space and the following rw init=/bin/bash .
[Note] ==== If your disk is encrypted, you may need to add `plymouth.enable=0` ==== . Press *Ctrl-x* or *F10* to boot the entry
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.
The system may take a moment to boot while SELinux relabels 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.
For additional information, specifically about live media using BTRFS, see also Restoring the bootloader using the Live disk
- Boot the Live installation media and choose Try Fedora .
- From the desktop, open a terminal and switch to root using su (the system will not ask for a password).
- To view your hard drive device nodes, enter df -H into the terminal. 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 .
mount /dev/sda2 /mnt/sysimage
mount /dev/fedora/root /mnt/sysimage
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
chroot /mnt/sysimage /bin/bash
Congratulations, your root password has been successfully changed.
Additional Troubleshooting
- If you cannot enter rescue mode because you forgot the Firmware/BIOS password here are some options:
- Refer to your computer’s documentation for instructions on resetting the Firmware/BIOS password in CMOS memory.
- Temporarily move the system hard disk to another machine, and follow the procedures above to reset the root password.
All Fedora Documentation content available under CC BY-SA 4.0 or, when specifically noted, under another accepted free and open content license.
Last build: 2023-07-13 20:50:18 UTC | Last content update: 2023-01-02
How to Reset a Forgotten Root Password in Fedora
This brief article explains the steps you can take to reset your forgotten root password on a Fedora Linux system. For this guide, we are using Fedora 32.
First, you need to reboot or power on your system and wait until the grub menu is displayed as shown below.
Press ‘e’ to edit the grub parameters. This ushers you to a display shown below. Next, locate the line beginning with ‘linux’ as shown below.
Using the Cursor forward Arrow key, navigate to the section with the rhgb quiet parameter.
Now replace the rhgb quiet parameter with rd.break enforcing=0 .
Next press ctrl + x to boot into single-user mode. Next, remount the root filesystem in read and write mode.
# mount –o remount,rw /sysroot
Next, run the command below to gain access to the Fedora system.
To change or reset the root password simply issue the passwd command as shown.
Provide a new password and confirm it. If all went well, a notification ‘password updated successfully‘ will be displayed at the end of the console.
To reboot the system, simply hit Ctrl + Alt + Del. You can thereafter log in as the root user using the newly created root password.
Upon logging in, run the command below to restore SELinux label to the /etc/shadow file.
And finally set SELinux to enforcing mode using the command.
And this concludes our topic on how to reset a forgotten root password on Fedora 32. Thank you for taking the time on this tutorial.
How to Reset Forgotten or Lost Root Password in Fedora
A Linux system administrator can quickly reset a user forgotten password using passwd command, but what happens if the system administrator itself forgets the root password? In this article, we will explain how to reset a forgotten or lost root user password in Fedora Linux distribution.
Note that to reset the lost root user password, you must have physical access to the Fedora machine in order to access Grub settings to reset and reboot the machine. Additionally, if your Fedora system is encrypted, you will also get to know the LUKS passphrase.
Edit the Fedora GRUB Settings
To edit the Fedora Grub settings, you need to interrupt the boot process by restarting the Fedora machine and press E on your keyboard when you see the following GRUB menu:
After pressing E on your keyboard, you will get the following screen.
Use your keyboard arrow keys and go to the line linux as shown.
After finding the linux line, remove rhgb quiet and replace with the following.
Once you have done with editing the line, press Ctrl-x to save and start the system.
Note: Adding enforcing=0 , bypass performing an entire system SELinux relabeling. Once the system is restarted, restore the appropriate SELinux context for the /etc/shadow file as explained below in this article.
Mounting the Fedora Filesystem
Once the system started in emergency mode, you need to remount the hard drive with read-write permission using the following command on the terminal.
# mount -o remount,rw /sysroot
Set Forgotten Root Password in Fedora
Now run the following chroot command to access the Fedora system.
You can now reset the forgotten or lost Fedora root user password using passwd command as shown.
Enter the new root user password twice when asked. If you are successful, you should get a message that all authentication tokens updated successfully as shown.
Type exit , twice to reboot the system.
Set SELinux Context on Shadow File
Log in as root user and type the following command to restore the SELinux label on the /etc/shadow file.
Turn SELinux back to enforcing mode.
That’s all! If you face any issues while resetting forgotten or lost Fedora root user password, do ask in the comments section below.
Сброс пароля fedora linux
Библиотека сайта rus-linux.net
‘e’ для того, чтобы получить возможность редактировать параметры grub. В результате откроется экран, показанный ниже. Затем найдите строку, начинающуюся с ‘linux’, как показано на следующем рисунке.
Находим строку с параметрами ядра
С помощью клавиши перемещения курсора со стрелкой «вперед» найдите параметр rhgb quiet .
Параметр ядра rhgb quiet
Замените параметр rhgb quiet на rd.break enforcing=0 .
Изменение параметра ядра в Grub
Затем нажмите ctrl + x , чтобы загрузить систему в однопользовательском режиме После этого смонтируйте корневую файловую систему в режиме с возможностью чтения/записи (read и write mode).
# mount –o remount,rw /sysroot
Монтирование корневой файловой системы в Fedora
Следующий шаг состоит в выполнении команды, показанной ниже, для получения доступа к системе Fedora.
Чтобы изменить или сбросить пароль root, просто введите команду passwd, задайте новый пароль и подтвердите его, как показано на следующем рисунке.
Изменение пароля суперользователя в Fedora
Если все пройдет успешно, в консоли появится уведомление ‘password updated successfully‘ (‘пароль успешно обновлен‘).
Чтобы перезагрузить систему, просто нажмите Ctrl + Alt + Del. После этого вы можете войти в систему как пользователь root, используя только что созданный пароль.
После входа в систему выполните приведенную ниже команду, чтобы восстановить метку SELinux в файле /etc/shadow.
И, наконец, установите SELinux в усиленный режим с помощью команды:
На этом мы завершаем рассказ о том, как сбросить забытый пароль пользователя root в Fedora 32 Спасибо, что нашли время прочитать этот текст.
В заключение приведем перечень всех опубликованных на Tecmint статей о восстановлении забытого пароля в дистрибутивах Linux:
Полагаю, что минимальных знаний технического английского достаточно, чтобы понять содержание статьи, которая вам покажется интересной.