Reset & Change Forgotten Root Password on RHEL 6 / CentOS 6

There are three types of user present in the Linux OS. These are Normal User, System User and Super User. The Root is the User known for Super User in Linux and in Windows it is known as Administrator. The First of all it is known as the main user for all operating systems operations. In this tutorial we have Discussed about the Recovery of Root Password Using Single User Mode on RHEL/ CentOS /Scientific Linux/ Oracle Linux 6/5 Rescue and Recover the Password without reinstalling the Linux OS.

Introduction to the Run Level and Single User Mode

Sometimes it may happen that you can’t remember the root password of your Enterprise Linux OS. Normally, your Enterprise Linux runs under runlevel 3 or 5. And booting through runlevel 1 it will allow you to enter into the single-user mode.

So now here we are going to recover a root password using a single user mode. But before that you should know about the Runlevels which are used in the Linux.

There are seven (0-6) runlevels which we use in Linux, here we will not going to discuss deeply about it. Just we take an overlook on it.

  • runlevel 0- Is used for halt/shutdown.
  • runlevel 1- Is used for single user mode (You can use “s” also to enter into the single user mode).
  • runlevel 2- Is used for multi-user mode, but without NFS (means without using the networking).
  • runlevel 3- Is used for multi-user mode with NFS and Networking
  • runlevel 4- Is not in user (But it is user defined runlevel so you can set your own runlevel [we will discuss it later].
  • runlevel 5- Is used for multi-user mode with X-11 (To enter into the graphics mode)
  • runlevel 6- Is used for Reboot.

So in this tutorial we use runlevel 1 means single-user mode to recover root password. Few steps to do it.

Recover Root Password using SingleUser Mode on RHEL/CentOS 6/5

Step-I(Starting of the RHEL/ CentOS /Scientific Linux/ Oracle Linux 6/5 OS)

While booting hit arrow keys it will take you to the following window.Use arrow key to select the entry that you want to modify. And hit “e” key to edit this.

Step-IStarting-of-the-RHEL-CentOS-Scientific-Linux-Oracle-Linux-6-5-OS

After hitting “e” it will take you to the next step.

Step-II(Edit grub setting)

Now you will see the following screen.Do the following step.

Step-IIEdit-grub-setting

Hit “e” from your keyboard. It edits the grub setting and pass you to kernel setting. Now follow the next step.

Step-III(Edit kernel arguments)

Hit “e” to edit kernel it take you to the prompt of crash kernel. Now follow the next step to enter into the single-user mode.

Step-IIIEdit-kernel-arguments

Step-IV(Boot into single-user Mode)

Enter 1 or s in front of “rhgb quit”. And hit Enter key.

Step-IVBoot-into-single-user-Mode

Step-V(Starting of Single User mode Prompt)

Now it will take back you to the kernel setting prompt. Just press/hit “b” to Boot it from the kernel and it takes you to the single-user mode.

Step-VStarting-of-Single-User-mode-Prompt

You are now in a single user mode, now you can reset your root password.

Step-VI(Disabled SElinux policy)

First check whether your selinux permits you or not.

It has three content:

  1. Enforcing-(Does not give you permission to reset your password)
  2. Permissive-(It gives you permission)
  3. Disabled-(No policies are loaded)

setenforce 1 is used for enforcing mode and setenforce 0 is used for permissive mode. Now we want permission from

selinux to reset our password just hit following command.

getenforce is a command use to check the selinux policy.

Type setenforce 0 and Hit enter key

Step-VIDisabled-SElinux-policy

Step-VII(Reset Root password)

Type passwd command and press enter key.

Step-VIIReset-Root-password

Step-VIII(Set New Root Password)

Type your password for Root and press enter key.

Step-VIIISet-New-Root-Password

Retype password and press enter key.

Step-VIIISet-New-Root-Password-Type-the-Password

Here I use weak password so it gives Bad Password line. But if you use complicated passwords for your root it won’t give you such a line and it will directly update your token without any difficulty.

Step-VIIISet-New-Root-Password-changed-sucessfully

Step-IX(Reboot the System)

Now reboot or just hit “init 6? command. And work with root as with your password.

Final Result

That’s all now, you have just Rescue & Recover the Root Password on Linux Distributions.You are now ready to use the Root Account on your systems. Just Boot to the Systems and to see the action of the Root User. Ensure that the Root Password is changed perfectly with the Linux systems. Enjoy the Powerful Root User Account on your system. Any difficulties regarding the Rescue & Recover the Root Password use the comment section below.

Hot Right Now

Related Post

COMMENTS