
It happens sometime that you can't remember root password. On Linux, recovering root password can be done by booting Linux under a specific mode: single user mode.
This tutorial will show how to boot Linux in single user mode when using GRUB and finally how to change root password.
During normal usage, a Linux OS runs under runlevels between 2 and 5 which corresponds to various multi-user modes. Booting Linux under runlevel 1 will allow one to enter into a specific mode, single user mode. Under such a level, you directly get a root prompt. From there, changing root password is a piece of cake.
Some Linux distribution, such as Ubuntu for instance, offer a specific boot menu entry where it is stated "Recovery Mode" or "Single-User Mode". If this is your case, selecting this menu entry will boot your machine into single user mode, you can carry on with the next part. If not, you might want to read this part.
Using GRUB, you can manually edit the proposed menu entry at boot time. To do so, when GRUB is presenting the menu list (you might need to press ESC first), follow those instructions:
The kernel should be booting as usual (except for the graphical splash screen you might be used to), and you will finally get a root prompt (sh#).
Here we are, we have gained root access to the filesystem, let's finally change the password.
As root, changing password does not ask for your old password, therefore running the command:
# passwd
will prompt you for your new password and will ask you to confirm it to make sure there is no typo.
That's it, you can now reboot your box and gain root access again








It looks like a security fail
If I want to get a pass from anybody, I only need to do this, come on, this is so easy, not even in windows is that easy to get a pass.
Well, here it goes for
Well, here it goes for windows password: http://home.eunet.no/~pnordahl/ntpasswd/ ....
Debuntu
If you get asked for the
If you get asked for the root password when entering single user mode use 'init=/bin/bash' on the kernel append line which should boot the machine into a bash console where you can get read/write access to your /etc/shadow file. You can then either run `passwd` or edit the shadow file directly to put in an empty string. This allows you to reboot the machine into its normal environment and login as root leaving the password blank and then run the `passwd` program to set the root password. This should really only be done when the machine is detached from any networks.
Chris
Spanish Translation
And fedora I did using following steps
I got it working after following some more steps and have blogged it here:
http://digitalpbk.blogspot.com/2009/03/reset-root-password-linux-fedora-debian.html
Easier method
You do not need to be in single user mode.
It is much MUCH simpler to reset this, I will tell you how.
Open a terminal program (command line, X terminal, whatever you want.)
type:
sudo su
You know are acting as 'root' of your system.
now type:
passwd
it will say: "Now changing password for root" or whatever. Just follow your computer's directions from here.
Any questions to emilio140790@hotmail.com for I will not look at this message place again (probably)
This is true, but this
This is true, but this suppose that you have a sudo account in the first place.
Debuntu
In what fucking distro can
In what fucking distro can you do this?
This works under Redhat but
This works under Redhat but NOT under ubuntu feisty.
Feisty will ask you for the root password when you try to boot into single user mode, as will SuSE and Solaris for that matter.
I don't know if previous version of ubuntu or debian behave this way or not.
This is why it is important to ALWAYS have a grub password when using Redhat/Fedora.
alternative
If you get asked for the root password when entering single user mode use 'init=/bin/bash' on the kernel append line which should boot the machine into a bash console where you can get read/write access to your /etc/shadow file. You can then either run `passwd` or edit the shadow file directly to put in an empty string. This allows you to reboot the machine into its normal environment and login as root leaving the password blank and then run the `passwd` program to set the root password. This should really only be done when the machine is detached from any networks.
It works with Ubuntu Feisty
> Feisty will ask you for the root password when you try to boot into single user mode,
I just tried it out. Ubuntu Feisty does not ask for the root password. But Debian Etch does.
However, as long as it is not encrypted, you can edit /etc/shadow with a live distri.
Use encryption. My Debian
Use encryption. My Debian Etch has one aes-encrypted Partition. This is a container for all the partitions, including swap. Only /boot with grub and the kernel is unencrypted.
When starting I am asked for the password. That's it.
Of cause, my usual identity does not have sudo-right. I am not ubuntu.
Maybe someone changes my kernel. I should calculate a sha1 right after after startup. But that's paranoid.
You can do this on Ubuntu at
You can do this on Ubuntu at least.
I believe you can to this on many different debian based distro, as well as many different other distro usig Grub.
Debuntu