This applies to CentOS servers running GRUB
To regain access to a server that you no longer know the root password to, you need to gain physical access to the server, and boot into single user mode. This will then allow you to change the root password.
Single-user mode will boot your system, mount the local file systems, and leave the network disabled. This will give you access to a command prompt, from which you can change the password.
To boot into Single-user mode, do the following steps.
- Turn on the computer, and when your show the GRUB screen, press any key to enter the GRUB interactive menu
- Highlight Red Hat Enterprise Linux with the kernel version you want to boot, and press the “a” key on your keyboard to append into on to the line
- At the end of the command, put a space, and type the word single then press enter.
Once you have gained access to the server, simply type passwd to set a new password, then reboot your computer normally.