Have you ever lost your root password on a Linux install? It can be painful casting about for your password, lifting keyboards and thumbing through your wallet in hopes of a moldy sticky note with scrawled pencil on it.
Well relax friend, there’s an easier way to recover your root password. You just reset it!
To do this, you’ll need to enter something called Runlevel 1. It’s not quite like that level in Super Mario Bros., but close. Here you’ll be accessing the computer in what’s called Single User Mode (no reflection on your marital or dating status). The only catch is you’ve pretty much got to do it in person (or through a TTY console).
How to do it? Let’s reboot to start with. Please also note that this tutorial focuses on Linux based on debian with Grub as a bootloader. (Yes, that includes Ubuntu).
Once your computer shuts down, hover your hand over the the keyboard and prepare yourself for some fast ESC key action. As soon as you see the word GRUB appear on your screen, tap that ESC key.
Now, go to the top option (the most recent kernel) and we’re going to edit it to boot into single user mode. This edit is a one time thing, so afterwards you can forget you’ve ever done this.
First, while the entry is highlighted, press ‘e‘. Next, go to the kernel line (something like “kernel /boot/vmlinuz-. . .“) and press ‘e‘ again.
Now, using those handy arrow keys, go the very end of the line and leaving one space, type:
single
Press that ESC key again, and then for a slight change of pace we’ll try the ‘b‘ key to boot your machine.
You’ll see a bunch of text scroll by as you boot into the text only Single User Mode (again, no reflection on your man or woman hood).
After a bit, it will spit up a prompt for you. Congratulations! You’re the root user. Now all that’s left is to change the password to something you know.
passwd
When prompted, enter in something wonderfully secure and robust.
Now reboot by typing reboot.
Technorati Tags: root password, linux, debian, ubuntu, recover root password, root vegetables
Popularity: 2% [?]












May 22nd, 2007 at 11:08 am
Hi,
.
this is not true for all distro es Suse require root password also in init S; you must have the 1st installation cd, if i remember well
I like your blog
Cheers
Marco
May 22nd, 2007 at 1:54 pm
So everyone can just change the root password of my computer? Doesn’t sound very safe to me.
But I do like your blog
Bert
May 23rd, 2007 at 7:53 am
Hey Marco,
You’re correct!
Bert, it’s something of a failsafe. That’s why you’ve not only got to watch out for crackers, but social engineers as well.
“Hi, I’m here to check the AC in your server room”.
May 23rd, 2007 at 11:04 am
Can’t you also do this (in Ubuntu) by choosing the “recovery mode” option in the GRUB menu? I believe that that boots into single user mode as well, although I’m not sure.
July 25th, 2007 at 1:45 am
Not true. My system, continues to ask me for a password, a root password in this case, which is why i tried the single mode in the first place. Debian Etch is what i am using. Any ideas on how to clear it? The machine cant boot from cd, usb, nor floppy. Any other idea than pulling out the hard drive and pluggin it into an external case and installing from scratch using another machine?
July 25th, 2007 at 7:28 am
Hmmm Albert,
You could try getting a live CD or something along the line of Knoppix and editing the /etc/shadow file.
You may be able to get around it that way.