CentOS 6 | Root Password Reset (GRUB Method)
Imagine the situation where your Administrator is fired/quits, and with him takes the root password of the server and need access to the server right now. Fortunately, Linux makes the process incredibly easy since you have local access, at least in the eyes of the Linux OS. All this method requires is the ability to manipulate GRUB, so if you have a way of seeing the grub menu and working with it, then this method is for you.
Let’s get started:
- Boot to the grub menu
- At the Grub menu press ‘e’ for edit.
- You should see 3 lines, scroll to the kernel line
- Using the Right Arrow, scroll to the end of that line
- Type the number “1” at the end and then hit “Enter”
- Now you’re looking at the 3 line again, hit ‘B’ to boot with this configuration
- Note: This is not saving the configuration, just booting you into Single User Mode for this session.
- You should now be booted into Single User Mode with Root access. Change the password with the “passwd” command
- # passwd
- Reboot the server with the “reboot” command
This method is great for 1&1’s Dedicated Servers using the Serial Console, 1&1’s Cloud Servers using either the KVM/VNC console, and Digitalocean’s KVM console. As long as you can see GRUB, you can change the root password.