Thursday, January 17, 2008

Linux Fundae: Recover lost root password

Try to boot linux in single user mode
For LiLo type ‘linux 1′ or ‘linux single’ at your LilLo boot prompt. If it asks for root password then this step will not work try next step.
For GRUB, at the boot screen press e, this will allow you to edit boot line. Append ’single’ to the boot line. Press enter then press b to boot with this modified boot line.
If you do not get the command prompt, follow the next step, otherwise you have the root file system mounted read only to you, you need to change this to rw. You can do this with mount -o remount,rw
Now you can change the root password by passwd command, or edit the /etc/shadow file, and remove encrypted password (by removing everything between first : and second : in the entry for root
If this method does not work. Do the following
For LiLo type ‘linux init=/bin/bash’ at LiLo boot prompt.
For GRUB press e. Append ‘init=/bin/bash’ to the boot line. Press enter and then press b.
Now you have the root file system mounted read only to you, you need to change this to rw. You can do this with mount -o remount,rw
Now you can change the root password by passwd command, or edit the /etc/shadow file, and remove encrypted password (by removing everything between first : and second : in the entry for root)

No comments: