I administer a LOT of Linux systems. Most of those systems information are in a file I keep that tells me what their passwords are. I normally either do not forget a root password or do not lose the paperwork for a Linux system. But I have been in situations where a new client had no idea what their Linux root password was. In those instances I had to change the root password. Problem is, if you don't know the root password, how are you going to change it? You need to know a method of password recovery for the Linux operating system.
There is a way to do this. It will work with most systems that use a root password. Of course if we're talking about a lost boot password, you're out of luck...this won't help you recover that. What this method does is reboot your machine into what is called "single user mode". Single user mode is also referred to as maintenance mode and is runlevel 1.
Reboot the Machine
The first thing you need to do is reboot the machine in question. The next step will vary, depending upon your distribution. What you need to do is to get to the screen that allows you to select which kernel to boot. Some systems (such as Fedora 10) require you to hit the escape key before the kernel boots. Some systems require a Ctrl-x key combination. Some systems require you to hit the "e" key. With Fedora 10 the sequence is this: After your bios posts you will hit the escape key to open up the Grub boot menu. In that menu select the kernel you are going to boot and hit the "a" key (for "append"). What you will see is the kernel boot command for your machine. What you need to do is append single to the end of that command (make sure there is a space before single) and hit the enter key.
Your machine will now start the single user boot process. You will see some processes list as "fail". Do not worry about this. Eventually you will find yourself at a root prompt. At this point all you need to do is enter the command passwd and then type the new password for the root user when prompted.
Once you have entered the new root password reboot the machine by issuing the reboot command. When the machine reboots you will have recovered the root password. Congratulations!
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.