HOW TO RESET FORGOTTEN ROOT PASSWORD IN RHEL/CENTOS 7
In this article we are going to learn how to reset forgotten root password in RHEL 7 / Cent OS 7. On my previous post i have explained the same topic but for Cent OS 6. Then I got a comment from one of my subscriber to write an article for RHEL 7.
Follow the steps below to reset forgotten root password:
Step : 1 Edit the GRUB
Start the System and press any key to interrupt the normal boot process, then you will able to see the screen as shown below, Here Select the GRUB option ( Highlighted in Blue Color on Snapshot below ) and press “e” to edit it.
You can also see the message showing by system on the lower portion of the screen as shown on the snapshot below.
Note : You can select the menu by using UP and DOWN arrow.
Step : 2 Make Changes in Kernel
After edit the GRUB look for the kernel line starting with linux16 as highlighted below on snapshot below.
Note : The below screen is Scrollable, You can use the UP and DOWN arrow to Scroll the Screen.
Here go to the end of the line and just after the word UTF-8 write rd.break ( Highlighted in Blue Color on the Snapshot below ) and then Press Ctrl+x ( Highlighted in Yellow Color on the Snapshot below) to go for further process. Follow the Snapshot below.
After press the Ctrl+x It will take to a Console as shown on the snapshot below.
Also Read :
Step : 3 Give Write Permission to /sysroot
Here we need to mount the /sysroot with rw ( Read/Write ) permission to reset the root password as by default the /sysroot would be in ro ( Read Only ) Permission mode.
We can check that by using mount command, Follow the snapshot below.
So let’s mount /sysroot with rw ( Read / Write ) Permission using below command
As we can see on the snapshot below now /sysroot is with rw ( Read / Write ) Permission.
Now here type command chroot /sysroot/ to treat the directory as a root and will redirect you to a shell prompt as shown below.
sh-4.2#
Step : 4 Reset the root Password
So now we are with a Shell Prompt. Here we can reset the linux root password using passwd command as shown on the snapshot below.
Note :
As we can see on the snapshot above root password updated Successfully now run the below command to Relabel the filesystem for SElinux automatically.
Note : After make any changes it is Recommended to relabel the file system to make all the applications start with proper label.
Then run exit command to come out from Shell Prompt and then run reboot command to restart the system.
Now you can use the new password for user root to login the system, So This is how we can reset Forgotten root password.
If you found this Article useful then Like it, Share it, Subscribe our Site for more Linux Tutorials OR If you have any thing to say then feel free to Comment on Comment Box below.