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.

About Andrew Lin

Hi, I have always wanted to creat a blog site but never had the time. I have been working in Information Technology for over 15 years. I specialize mainly in networks and server technologies and dabble a little with the programming aspects. Andrew Lin

View all posts by Andrew Lin →