How to reset root password in Centos 7, Redhat 7 ,Fedora

Share on :

How to reset root password in Centos 7 , Redhat 7


   Firstly you have to boot your system and enter on the Bootloader screen

How to reset root password in Centos 7, Redhat 7 ,Fedora

   Then you have to edit the default bootloader entry

   To do this you have to press the 'e' button to edit the entries on the bootloader.

How to reset root password in Centos 7, Redhat 7 ,Fedora

NOTE: DONOT ENABLE THE CAPS LOCK ON, IF YOU ENABLE CAPS LOCK THEN YOU CANT EDIT THE BOOTLOADER

How to reset root password in Centos 7, Redhat 7 ,Fedora


In the bootloader you have to pass a paramater:

Using the cursor keys, navigate to the line that starts with "linux16".
Move the cursor to the end of the line by pressing the 'End' button.
Now write this parameter rd.break console=tty0
Then press 'ctrl+x' to boot into the modify config.

How to reset root password in Centos 7, Redhat 7 ,Fedora

At the switch_root

switch_root: / # mount
How to reset root password in Centos 7, Redhat 7 ,Fedora
switch_root: / # mount   -o   remount,rw   /sysroot
How to reset root password in Centos 7, Redhat 7 ,Fedora

switch_root: / # mount
How to reset root password in Centos 7, Redhat 7 ,Fedora

switch_root: / # chroot   /sysroot

sh-4.2# passwd root
Enter the password:
Again enter the password:

How to reset root password in Centos 7, Redhat 7 ,Fedora

*THEN YOU HAVE TO CREATE THE AUTORELABEL FILE TO RECREATE THE /etc/shadow FILE, IT IS NECESSARY TO MAKE THIS FILE BECAUSE THE NEW PASSWORD IS SAVED IN THE SHADOW FILE AND IT IS OVERRIDDEN.

sh-4.2# touch /.autorelabel
How to reset root password in Centos 7, Redhat 7 ,Fedora

*NOW BOOT THE SYSTEM AS NORMAL BY TYPING EXIT

sh-4.2# exit
switch_root:/# exit

How to reset root password in Centos 7, Redhat 7 ,Fedora

--------------------------------------------------------------------------------------------------------
The Video Below is a detailed guide :-


Share on :

You may also like...

1 Response

  1. Unknown says:

    Thank you sir

Leave a Reply

Your email address will not be published. Required fields are marked *