Sunday 13 January 2013

Linux Root Password Recovery Steps on RedHat/Cent OS




Step 1 #> Single User Mode
  1. Restart the Server
  2. Press Enter in Redhat Enterprise Linux (2.6.32-71.el6_64)
  3. Press e edit
  4. Select the 2nd line which will start the word from kernel
  5. Press e to edit
  6. Type single or s or 1 in end of the line (after rhgb quiet words)
  7. Enter
  8. Press b to boot in single user mode
  9. Shell will come
  10. Type the passwd command and enter the new password for root account


Step 2 #> CD Rescue Mode
  1. Bash-4.1# This shell is read only so follow the step to read/write mode
  2. chroot /mnt/sysimage (This will change the shell to sh-4.1#)
  3. Type the passwd command and enter the new password for root account
OR
  1. Vim /etc/passwd and delete the x letter only (encypted passwd) in root user line.
Ex: root:x:
Step 3 #> Account Lock Remove
  1. Do the same as Single User Mode and run the below command for Unlocking the root user account
  2. Shell> passwd –u root
Step 4 #> Password Expiry Remove
  1. Go the Single User Mode
  2. Shell>chage –l root (To check the account status of root user)
  3. If Account expired run the below command
  4. Shell>chage –E never
RedHat Linux Grub Password Recovery Steps:
  1. If you know the root password just remove the password line from /etc/grub.conf
  2. If you know the root password and want to change the grub password do the below steps
Shell> grub-md5-crypt
#copy the encrypted password and paste it in /etc/grub.conf as like below after the line “timeout”
Password - -md5 encryptedpassword
Ex:
default 0
timeout 8
password --md5 $1$lS2dv/$JOcHkLosIn7CJk9xShzzJVw/
  1. If you don’t know the grub password and root password do the following steps
#Use the CD Rescue Mode and check the grub.conf file
Shell>vim /boot/grub/grub.conf
#Correct the grub.conf file


1 comment:

  1. I am using scientific linux 6.3, I wanted to rescue from cd but when I wrote chroot /mnt/sysimage; I got a message: command no recognize

    ReplyDelete