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
- Reboot the server and get to the Grub Menu
- Go to the line that says “linux16”.
- There’s going to be a few more lines compared to CentOS6‘s method, just scroll slowly, it’s there.
- Using the Right arrow, go into the “linux16” line and find the word “ro”.
- This is telling the server to boot into Read Only. The server boots that and then upon login/mounting you get a Read/Write access. We want to bypass that.
- Change “ro” to “rw” and follow it up with “init=/sysroot/bin/sh”
- “ro” becomes “rw init=/sysroot/bin/sh”
- Press Ctrl-X to boot with this configuration
- Note that this doesn’t save the configuration, just lets you boot into it for this Session
- Now you should have Root access, type the “passwd” command to change the password.
- Reboot the server and use your new password to login.
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.