Forgot the root password for my Red Hat Enterprise Linux 5 server, how do I change it?

I built this Red Hat Enterprise Linux 5 server in VMware a while ago and forgot the root password. I can log in as a user but it does not have the privileges to change the root IDs password. Well, fear not you can reboot the server into single user mode and change root’s password.

To enter single user mode, reboot the server. When you see the Red Hat Enterprise Linux 5 splash screen, press any key to enter the boot menu.

Red Hat Enterprise Linux 5 boot screen

Red Hat Enterprise Linux 5 boot screen

At the boot menu highlight the installation you want to edit, usually the first one, then type ‘a’ (without quote) to enter into append mode.

You are presented with a prompt that looks similar to the following:

Grub append> ro root=/dev/VolGroup00/LogVol00 rhgb quiet crashkernel=128@16M

Red Hat Enterprise Linux append mode

Red Hat Enterprise Linux append mode

Press the spacebar once to add a blank space, then add the word single to tell GRUB to boot into single user mode. The result should look like the following:

ro root=/dev/VolGroup00/LogVol00 rhgb quiet crashkernel=128@16M single

Press enter and the server will reboot into single user mode. You will then be presented with a shell prompt similar to the following:

sh-2.05#

To change the root password type passwd root, you will then be asked to type the new password twice as shown in the following image.

Red Hat Enterprise Linux single user mode

Red Hat Enterprise Linux single user mode

After the password has been updated successfully then type reboot to restart the server in normal mode. You have now completed changing the root password. Red Hat will warn you if your password is not secure enough as you can see in the image above, “BAD PASSWORD: it is based on a dictionary word”. You have the option the change the password again by typing passwd root again.

Be Sociable, Share!

12 comments for “Forgot the root password for my Red Hat Enterprise Linux 5 server, how do I change it?

  1. AMIT MAURYA
    September 7, 2012 at 3:54 pm

    thank u sir . it really worked……

    thanks a looooooooooooootttt

  2. Davidp
    July 31, 2012 at 8:21 pm

    Red Hat Enterprise Server
    Neither “a” nor “e” do anything at all.

  3. rahul
    July 5, 2012 at 12:07 am

    thank you sir i have forget the pssword but after try as u said i was able to login with user name root.
    thanks a lottttttttttttttt.

  4. vijay akula
    June 16, 2012 at 12:57 pm

    same for me . i tried the same on mu virtual m/c but it does not working

  5. Milind
    May 25, 2012 at 2:13 am

    Works like a charm! Great! Thanks.

  6. JRodriguez
    April 11, 2012 at 10:20 am

    You should press ‘e’ for edit not ‘a’ for append.
    After adding single at the end then press enter and then ‘b’ for boot.
    I know this is an old post but wanted to let other users havng the same issue.
    Thanks,
    JRodriguez

  7. sirish
    January 25, 2012 at 2:55 am

    Workingggg good

    Thanx 4 d solution.

  8. shyam akula
    November 30, 2011 at 7:56 am

    Thank u… it worked for me..

  9. mohammed
    August 7, 2011 at 1:28 pm

    i tried to do this trick on my virtual redhat enterprise linux 5 server but after typing “a” (without quote) …… i got nothing, just the string “grub append>” (without quote)

    when i choose to edit the kernal “e selection” i got these 4 lines :

    root(hd0,0)

    kernal /xen.gz-2.6.18-8.el5

    module /vmlinuz-2.6.18-8.el5xen ro root=dev/VolGroup00/LogVol00 rhgb quite

    module /initrd-2.6.18-8.el5xen.img

    So, what shall i do NOW ??

    • August 29, 2011 at 3:19 pm

      Sorry for the delayed response. But I am sure you figured out a solution by now.

  10. VS Sekhar
    July 14, 2011 at 1:59 am

    Great!!

    Thank you very much

  11. SAKTHI
    January 12, 2010 at 2:37 am

    Thanks a lot

Leave a Reply

Your email address will not be published. Required fields are marked *