Reset Root Password in RHEL 7/Centos7 for Linux VM

Few months back only, Red hat launched its major release 7 of Linux operating system. RHEL 7 is a major release as many of the system properties and services are changed in it. It uses Kernel version 3.10.0 and its support for VMware Tools and 3D graphics drivers is out of the box. Today in this video we are going to show you how to reset root password for your Red hat 7 or Centos 7 server if you have forgotten it in a virtual machine.

RHEL 7 Reset root password

If you have used Red hat Enterprise Linux 6, then you must be knowing that root password for Linux servers can be reset using single user mode. But in Red hat Enterprise Linux 7 you can’t do it the same way.

Recommended Article: How to Login to your Hostgator Hosting Account using SSH

Now in RHEL 7, GRUB 2 requires root password to work on single user and emergency mode. So you can’t even go to single user mode without the root password. If you have forgotten your Linux root password, then you can use below steps to reset it.

Note: This workaround is specially for Linux Virtual Machines which I found recently.

Steps to Reset Forgotten Root Password in Red hat/Centos 7 in a Virtual Machine


1. Restart your Virtual Linux machine and on the GRUB 2 boot screen, press the space or an arrow key to stop further booting.

2. Now press “e” key to edit. You will be shown grub screen.

3. Scroll down and add the following parameter at the end of the linux16 line, or linuxefi on UEFI systems. You can refer below video if you are having any problem. You can press Ctrl+e to go last of that line directly.

# init=/bin/sh

grub 2 edit for root password reset RHEL7

The above modification in GRUB 2 will boot Linux kernel in the /bin/sh shell rather than the system init daemon.

4. Now you will be shown command prompt but you can’t reset the root password because the file system is mounted read-only mode. So use below command to make filesystem writable.

# mount -o remount,rw /

Note: You won’t be shown any text in the screen.

5. Run the passwd command to change the root password. But if you get “Authentication token manipulation error“, then it means your filesystem is not writable, perform step 4.

Workaround !!


You make also get a bad password error as below.

BAD PASSWORD: The password is a palindrome

Now here you have to do a workaround to get a temporary password to login. When asked for a password just press space key once and then confirm same at next prompt.

You will notice that your password will get accepted and you are good to proceed.

Recommended Article: [Solution] Bash Vulnerability (CVE-2014-6271 and CVE-2014-7169)

6. Now you will have to run below command to make sure that SELinux context of the files that were modified is restored properly after boot.

# touch / .autorelabel

7. Run the below command to resume the initialization process and finish the system boot.

# exec /sbin/init or # exec /sbin/reboot

8. Now you will see your login screen, just use not listed option as shown in the video and enter root as username and the space key as a password.

Bingo !!

Now you are logged in as root. Now change the root password to some strong one and do your task.


Hope you like this article and will surely share your feedback or questions with me. Do watch the above video for better understanding. Do not hesitate to share this video within your social network and do subscribe to our blog for more such videos.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.