Notice: Due to size constraints and loading performance considerations, scripts referenced in blog posts are not attached directly. To request access, please complete the following form: Script Request Form Note: A Google account is required to access the form.
Disclaimer: I do not accept responsibility for any issues arising from scripts being run without adequate understanding. It is the user's responsibility to review and assess any code before execution. More information

Reset Forgotton "root" password - Linux

Press e on your keyboard when you see this screen:

If you've done this correctly, you should see a screen similar to this one:

Use your arrow keys to move to the Linux16 line:

Using your del key or your backspace key, remove rhgb quiet and replace with the following:

rd.break enforcing=0

Setting enforcing=0 will allow you to avoid performing a complete system SELinux relabeling. Once the system is rebooted, you'll only have to restore the correct SELinux context for the /etc/shadow file. I'll show you how to do this too.

Press Ctrl-x to start.

The system will now be in emergency mode.

Remount the hard drive with read-write access:

mount –o remount,rw /sysroot

Run chroot to access the system:

chroot /sysroot

You can now change the root password:

passwd

Type the new root password twice when prompted. If you are successful, you should see a message that reads "all authentication tokens updated successfully."

Type exit twice to reboot the system.

Log in as root and restore the SELinux label to the /etc/shadow file.

restorecon -v /etc/shadow

Turn SELinux back to enforcing mode:

setenforce 1

Previous Post Next Post

نموذج الاتصال