Wednesday, January 19, 2011

Lost your root password?

Just finished a fresh install of CentOS 5.5, and in my pangs of hunger, I found myself locked out of my root account, as I was unable to remember the bloody password I set 5 minutes ago.

This outlines how to quickly change the root password if locked out.

1. Boot into single user mode. Boot the machine and at the start up options, press a to append to the GRUB loader config.
The following text should be visible
ro root=LABEL=/
Delete any text after this and append the following line (be sure to include a space after the slash)
It should look like this
ro root=LABEL=/ single

The Single user prompt should appear after booting:

2. Change the root password
Enter the following command to change the root password:
passwd root

You will be prompted to change and confirm the new root password

3. RebootUpon reboot, you should be able to access the root account.