Wednesday, September 28, 2011

Resetting root password in linux

In my short career as Linux system administrator , i have seen users forgetting their system's root password and thinking "ahh i have to build my system again" but fortunately the password can be reset , all it needs is a re-boot.

Note - If Grub password is set and you forget even that , no body can help you !

Here are the steps to reset it.

I will be using my RHEL system as an example.

STEP 1

Reboot your system , before it boots into the default kernel , press e to enter the GRUB menu



STEP 2

Again press e ( edit ) to see the location of the initrd image using the arrow keys select the kernel vmlinux option ( 2nd option in the screen shot below )



STEP 3

Press e gain and type s next to quite , press to go back to previous screen and type b to reboot the system



STEP 4

Now the sytem boots to single user mode , just type passwd and set your password and restart your system ( you can type init 6 here)



Now you can login with your new password .ENJOY !!!


Thanks,
vedaprasad


4 comments:

  1. this is useful info... but any user can just restart the system and change the root passwd with this approach right??..

    ReplyDelete
  2. Yes,that is why need to set GRUB password as well .

    ReplyDelete
  3. So when you have to get into the GRUB menu itself, does it ask for the GRUB password?.. I am new to Linux systems and hence the novice questions...

    ReplyDelete
  4. If grub password is not set then it won't ask for any password , to get into GRUB Menu.

    to set grub password -
    type "grub-md5-crypt" as root
    an encrypted password will be generated , copy that and put it in /boot/grub/grub.conf as
    password -md5 "generated encrypted password".

    ReplyDelete