Monday, August 1, 2011

Recover Root Password in CentOS/RHEL 5.6/6

You can log in using single-user mode or rescue-mode to reset the root password.


1) Log in to single-user mode
  1. Boot the machine andd wait until the GRUB message appears and hit any key.
  2. Select current kernel version that you wish to boot and type a to append the line.
  3. Then type single or 1 at the end of the line (there should be a space between single and the last parameter). Then Enter to proceed. 
    [root@hostname /]# passwd
    Changing password for user root.
    New password:
    Retype new password:
    passwd: all authentication tokens updated successfully.
    [root@hostname /]#

    RHEL 6.0 has a bug that will prevent you from changing your root password in single user mode.You may temporarily disable SELinux.  ()

    # setenforce 0

    2) Boot in to rescue mode
    1. Boot the machine using a CentOS/RHEL installation DVD or CD#1 and wait until the Welcome Screen appears.
    2. You can find three options,
      1. Install or upgrade an existing system
      2. Install system with basic video driver
      3. Rescue installed system
      4. Boot from local drive
      5. Select the Rescue installed system and Enter to proceed.
      6. Then it will ask you to Choose a Language and Keyboard Type. Choose appropriately.   
      7. Then you will find a dialog whether you need network setup. you can choos yes or no it want mater.
      8. Then you will find Rescue dialog box. Choose Continue option and hit OK twice and Start shell. Then you will be in the shell.
      Starting shell...
      bash-4.1# chroot /mnt/sysimage
      sh-4.1# passwd
      Changing password for user root.
      New password:
      Retype new password:
      passwd: all authentication tokens updated successfully.
      sh-4.1# exit
      exit
      bash-4.1# reboot

      3) Using recovery mode

      1. Chose root Drop to root shell prompt.
      2. mount -o remount,rw / this will mount your root diectory with read/write permission.
      3. Type passwd


      2 comments:

      MABM

      Demo: Create MBAM 2.5 users and groups in Active Directory Domain Services Configure MBAM 2.5 Roles for the instance of SQL Server ...