Friday, August 29, 2014

UBUNTU : How to reset root password in Ubuntu 10.04 LTS

In this how to we shall discuss how to reset root password in Ubuntu 10.04 LTS. I guess this howto will be of highly useful if you forgot your root password in Linux servers particularly in debian based systems like Ubuntu.

Single User Mode in Ubuntu 
To reset the root password you have to boot to single user mode. Follow to steps below to boot to the single user mode in Ubuntu 10.04 LTS.

Please note that Ubuntu 10.04 LTS use the GRUB 2 as bootloader. The first boot option will be used by GRUB 2 by default and it will be used for booting without waiting for user input. So you need tointerrupt the boot process for getting boot menu.

To edit the boot menu in Ubuntu 10.04 LTS
For that press down the "shift" key while booting and you will get the GRUB boot menu.

Normally the top GRUB entry will be pointing to your normal boot entries. It will look similar to:

            Ubuntu, with Linux ( kernel version + options)

Press the 'e' key to edit the kernel parameters.

Now what you see are the boot entries. Now find the kernel line and append "init=/bin/bash" to it.

The kernel line will look like:
            linux root=UUID=xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx ro vga=794 quiet splash

Go to the end of the line using your arrow keys and append init=/bin/bash to it as follows:

            linux root=UUID=xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx ro vga=794 quiet splash init=/bin/bash

Now boot with the edited kernel parameter by pressing ctrl+x.

Your machine will now do a one time boot into single user mode. Once you reboot the changes you just made to Grub will be reverted.

Remount root partition as read/write in single user mode and reset password
Now your /root partition will be mounted as read only. Type in the following command to mount the /root partition as read write.

             mount -n -o remount,rw /

Now changing the root password is a piece of cake!!! just type in:

             passwd root

And specify the new password.

In newer Ubuntu releases, you will UEFI supported entries also.

No comments: