In Gnu / Linux we can change the password of any user, anyone except root or superuser. Password that can only be changed if you are the superuser. But what if you forget the root password? What options are there to solve this? Should we reinstall the Gnu / Linux distribution?
Is there a solution for the problem of forgetting the root password, but it is true that each distribution has a different solution. Next we are going to explain how to make this root password change in Fedora. First of all, do not do this in production teams for fun because if there is an error you will lose all the information.
To change the root password we have to interrupt the start of Fedora Grub. We will interrupt it by pressing the E button when the Grub screen appears. A screen like the following will appear:
So we go to the Linux16 line and we change the word set «rghb quiet» by
rd.break enforcing= 0
Now we press Ctrl + X to continue the loading process. If the system is encrypted, it will now ask us for the LUKS password.
With this we have made the Fedora system load in emergency mode, now we have to mount the hard disk with the following command:
mount -o remount, rw / sysroot
And we execute the chroot command to access the system. By typing the following:
chroot / sysroot
And now we can run passwd command to change root password. After executing the command, we will be asked to enter the new root password twice. Now we write Exit twice to reboot the system. After that we start the session as root and restore the grub changes by typing this:
restorecon -v /etc/shadow
And later
setenforce 1
With this we will have the new root password changed and we will be able to function without having to reinstall or lose our data.
More information - Fedora Magazine
Be the first to comment