Fedora 41 Change root password
You can change your root password on several ways, if you forgot it.
The short way
sudo su
passwd
or
sudo passwd root
Or the long way
Restart the system: Restart the system or switch it on.
GRUB menu: Press a key (e or c) during the startup process to edit the GRUB startup menu (the boot loader).
Edit boot parameters: Find the line that starts with linux or linuxefi. Add a new parameter at the end of this line. In the past, this was often single or init=/bin/bash. Today, rd.break or rw init=/bin/bash is often used to put the system in a state where you can obtain a root shell without a password.
Remount the file system: In some cases, especially with the rd.break parameter, the file system is mounted as read-only. Before you can change the password, you must remount it in read-write mode:
mount -o remount,rw /sysroot
chroot /sysroot (to switch to the “real” system environment)
Change password: Now you can run the passwd command to change the root password: passwd.
Restore SELinux context: If you are using SELinux (which is standard in Fedora), you must create a file called .autorelabel. This ensures that SELinux correctly adjusts the file permissions after the reboot so that the system does not fail.
touch /.autorelabel
Restart the system: Finally, restart the system, usually with reboot -f or exit followed by exit.