Reset root password in RHEL 7

This document is helpful for reset RHEL 7 / CentOS 7 forgotten root password-----

Follow the following steps to reset the root password.

Note:  Be careful before doing any changes on a GRUB level. Typing error can be damage the OS booting.

>Start RHEL 7 server and select the following option which I have marked in the "Yellow"
Press 'e' to edit the selected item.


>Search for the "linux16" and remove the command "rhgb quiet". In the below image I have marked the command in Yellow text.


>Once you delete the command "rhgb quiet" add the new command "init=/bin/sh"in the end of the same line. In the bellow image find the added new command in "Yellow" text.


>Once new command is added, Press "Ctrl-x" to boot the server in shell.


 >In the boot process by default root file system is mounted read only, With the following command I am changing the root file system to read and write (rw).
Command: #mount -o remount, rw /

>Now I am going to change root password with "passwd" command.


>Run the following command to restore selinux settings.
Command: #touch / .autorelabel

 
>Restart the machine with the Command: #exec /sbin/init

  
  EOF

Comments

Popular posts from this blog

KVM Live Migration without Shared Storage

Create CentOS 6 Local package and Group package Repository

Create Linux ( LUCI ) Cluster