how to reset forgotten root password on debian GNU/linux lenny ?

Prerequisites : Debian GNU/linux Lenny 5.0.4, GRUB boot loader.

Read the whole post and then attempt to change root password. By default, you can edit entries in grub boot loader within five [ 5 ] seconds only.

There are two [ 2 ] situations depending upon your boot list.

Situation A : You have single user mode option in Grub boot loader.


Step 1 : Boot your system and wait for the grub to load. Select the Debian/GNU Linux, kernel 2.6.26-2-686 [ single-user mode ] with the down arrow or mouse and press e. The single user mode is highlighted in the image shown below :


Step 2 : Select the single-user mode using up or down key on keyboard : kernel /boot/vmlinuz-2.6.26-2-686 root=/dev/sda1 ro single. After selecting the single user mode, press e to edit the entry. Please read the text highlighted in yellow colour or on your system.


Step 3 : Append the following command at the end of the entry as shown in the image below. Notice that there is a space between single and init.

init=/bin/sh


Step 4 : Press enter after typing in the code given in the Step 3. It will show you the edited entry highlighted.


Step 5 : Press "b" [ on your keyboard ] and the system starts booting. It might look like this :


Step 6 : After the system has finished booting, it will provide you with a root prompt :


Step 7 : In order to avoid the error : "Passwd: Authentication token lock busy", type the following line at the root prompt. The command allows you to remount the filesystem in read write mode. After typing the command, press enter.

# mount -o remount,rw /


Step 8 : Type passwd at the root prompt in order to change the root password of your Debian Lenny OS and press enter.

# passwd


Step 9 : It will give a prompt you to provide a new password and type your new root password. This step allows you to change the root password. You have to provide only your new root password.


Step 10 : If everything goes correctly, it will show the message "passwd: password updated successfully" as shown in the image above.

Step 11 : Type the command given below in order to halt the system.

# halt


Step 12 : Power off your desktop or laptop.

Step 13 : Login into your user account and try to access your root account in a terminal :

$ su



By following the above steps you have successfully changed your root password.

Situation B : If there is no single-user mode option in boot loader :


Step 1 : Boot your system and wait for the grub to load. Select the Debian/GNU Linux, kernel 2.6.26-2-686 with the down arrow or mouse and press "e". The single user mode is highlighted in the image shown below :


Step 2 : Select the kernel using up or down key on keyboard : kernel /boot/vmlinuz-2.6.26-2-686 root=/dev/sda1 ro quiet. After selecting the single user mode, press e to edit the entry.


Step 3 : Append the following command at the end of the entry as shown in the image below. Notice that there is a space between quiet and init.

init=/bin/sh


Step 4 : Press enter after typing in the code given in the Step 3. It will show you the edited entry highlighted.


Step 5 : Follow the steps from Step 5 as given in Situation A.

p.s. All the screenshots are from my virtualbox machine. The real world screens might be somewhat different.

The End.
 
 
Creative Commons License
This work by © 2012 maniac.vardhan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

0 comments :: how to reset forgotten root password on debian GNU/linux lenny ?

Post a Comment