Pages

Monday, November 12, 2012

How to Reset Forgotten Root Password in RHEL/CentOS and Fedora

 
 
Suppose you want to get into a Linux system. You know nothing about the existing user’s or their passwords. You have no idea about these things. Then what will you do??
The only thing you know that the user root exists. So we must find a way to get the root’s password.
I think you know about the different run-levels on a UNIX machine. The single user mode or the run-level 1 is used for these kind of rescue purposes. So what you should do is to enter the rescue mode. Click here to learn How to enter Rescue mode in Linux / UNIX.
Once the Rescue environment is loaded, you will get a shell which is your default bash shell.
Now use the passwd command to set / change the root’s password.
[root@server ~]# passwd
Changing password for user root.
New password:
BAD PASSWORD: it is too simplistic/systematic
Retype new password:
passwd: all authentication tokens updated successfully.
Now the password has been changed the newly set one.
Note:
If you are using Red Hat Enterprise Linux 6, a security bug was there which blocked the passwd command from working in single user mode. Later this was fixed by a bug fix update (http://rhn.redhat.com/errata/RHBA-2010-0845.html).
If you have installed the original selinux-policy package, the passwd command might not run. So make the SELinux policy to permissive for the passwd command to run.
Get the SELinux status by,
# getenforce Enforcing
Now change to permissive by,
# setenforce 0
Again check the status and see the change
# getenforce Permissive
Now run the passwd command and after that change the SELinux back to the Enforcing state by the

# setenforce 1
# getenforce Enforcing
Now reboot the machine and boot normally.
Thats all you are done.

No comments:

Post a Comment