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 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
Step-I(Starting of the RHEL/ CentOS /Scientific Linux/ Oracle Linux 6 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.
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.
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-IV(Boot into single-user Mode)
Enter 1 or s in front of “rhgb quit”. And hit Enter key.
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.
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:
- Enforcing-(Does not give you permission to reset your password)
- Permissive-(It gives you permission)
- 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-VII(Reset Root password)
Type passwd command and press enter key.
Step-VIII(Set New Root Password)
Type your password for Root and press enter key.
Retype password and press enter key.
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-IX(Reboot the System)
Now reboot or just hit
init 6 command. And work with root as with your password.
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.