Root User Password Reset

Linux Tutorials

Download Root User Password Reset tutorial.

In this tutorial, I will be demonstrating how to reset the root user’s password on a CentOS 7 minimal install VM.

Refer to the prerequisites listed below to access the resources needed to complete this tutorial.

Prerequisites

  • VirtualBox VM with a CentOS 7 minimal install

For instructions on how to install VirtualBox and extension pack, see my VirtualBox Install tutorial here.

If you do not already have a virtual machine, with a minimal install of CentOS 7, my other tutorial, CentOS 7 Server Install, is here.



Steps to complete tutorial:


Start Virtual Machine

From the VirtualBox Manager interface, ensure your VM is selected and click Start



As soon as the VM starts, hit 'e' to edit the selected kernel menu entry (represents the newest kernel).



Edit GRUB Kernel Entry

You will see the menu entry for the selected kernel. Using your keyboard’s up/down keys, scroll down to the line that begins with linux16.





Once you have located the line that begins with linux16, you will have to replace: ro with rw init=/sysroot/bin/sh





Then, you will need to hit Ctrl + x to start the operating system in emergency mode, this is where we will reset the root user’s password.

Reset Password for Root User

Once you are in emergency mode, enter the following commands (one after the other):

# chroot /sysroot          // change to the new root directory
# password root            // reset the root user’s password
# touch /.autorelabel      // used to update SELinux filesystem contexts for next reboot
# reboot -f                // reboot the system



After resetting the root user’s password and notifying the SELinux subsystem to relabel the filesystem on reboot, you rebooted the system. You will now be able verify that the root user’s password was successfully reset.

Confirm Access To System

Now that the system has booted, login using your root user’s credentials.



We have confirmed that we successfully reset the root user’s password.

I hope you have enjoyed completing this tutorial and found it helpful.

If you would like to see my other tutorials, they can be accessed here.

Finally, if need be, you can download this tutorial Root User Password Reset.