Forgot your Linux root password? No worries! Our guide provides easy-to-follow instructions to reset and change it safely.
Have you ever found yourself locked out of your Linux system, staring blankly at the login screen because you can’t recall your root password? It’s a common scenario that can be frustrating, especially when you need urgent access to your system.
But fear not because in the world of Linux, forgetting your root password is not the end of the road. Our simple but proven effective guide is here to rescue you from this predicament.
Resetting Your Linux Root Password
To reset your Linux root password, you’ll need physical access to the machine or the console if you’re working on a virtual machine, as restarting the system is part of the procedure.
Change GRUB Boot Parameters
Reboot your Linux system, and when the GRUB boot menu appears, highlight the line with your distribution name, then press the “e” key to enter edit boot parameters mode.
Find the line starting with “linux” and make sure it contains “rw” and not “ro“. If not, change it. Then go and append “init=/bin/bash” to the end of the line, as the final version should be similar to the one shown below.
So, what did we do? Let me explain. In the context of GRUB boot parameters, “ro” and “rw” are options that specify how the filesystem should be mounted during the boot process:
- “ro“: This stands for “read-only”. When it’s used, the filesystem is mounted in read-only mode. It’s often a default setting for many Linux systems during the initial boot process to perform filesystem checks during the startup. Then, after the initial boot checks are complete, the system remounts the filesystem with “rw” to allow normal operations.
- “rw“: This stands for “read-write.” When this parameter is set, the filesystem is mounted in read-write mode. This means the system can both read from and write to the filesystem. It’s also the option we need because to reset the root password, we must set a new one. This involves writing to certain files on the file system, hence the need for “rw “.
Ok, but what about “init=/bin/bash“? In short, this parameter tells the system to start with the Bash shell as the initial process instead of the usual init system. As a result, this effectively gives you immediate access to a root shell without needing to log in, where we will be able to change the password for the root account.
Now that everything is in place, press “Ctrl+X” to start the boot process.
Reset the Root Password
The system will boot in single-user mode, and you will end up with a Bash shell with a logged root account.
To update the password for the root user, we simply need to execute the
passwd command and then establish a new one.
To enhance your proficiency in using the
passwd command on Linux, our comprehensive guide “How To Use passwd Command on Linux with Examples” will significantly benefit you.
And that’s it! You’ve successfully reset the root user password on your Linux system. Now, all you left to do is reboot your system, and you’ll be all set to regain access. Great work!
Forgetting your Linux root password is not the end of the world. With our straightforward guide, you’ll learn how to reset and change it safely and efficiently. We hope this process was simple to follow and helped alleviate any stress associated with this common issue.
Thanks for your time! As always, your feedback and comments are most welcome.