HomeHowTo › How To Reset The Root Password

How To Reset The Root Password

At some point you might get into the awkward situation that you have to administrate an old linux server, but you can’t remember the root password because you haven’t touched the server for a while. I’ll show you how you can easily reset the password in this case.

The only thing you’ll need is a bootable linux live CD. You can use Ubuntu in “Try Ubuntu” mode, OpenSuse in “Recovery” mode or, as I did in the example below, Backtrack 5 in “Forensics” mode. Other live CDs should be fine as well, but it has to be the same architecture (x86 or x64) as your installed system. If you have choosen a live CD, boot it up and follow these steps:

First thing you have to do is find out the name of the partition on which your installed system is located on. If you only have one hard drive it should usually be sda1 or sda2, but to find out you can use the fdisk command:

sudo fdisk -l

Once you found the correct partition you have to mount it. You’ll also have to bind the dev environment:

sudo mount /dev/sda1 /mnt
sudo mount --bind /dev/ /mnt/dev

After that you have to change your root directory from the live environment to the installed system:

sudo chroot /mnt

Now you can work in your installed system and easily set a new root password:

sudo passwd root

Finally exit chroot mode and reboot your computer:

exit
sudo reboot

And that’s it. You should now be able to log in as root using the new password.

Here’s a screenshot which shows this procedure executed on Backtrack 5:Reset Root Password

Leave a Comment