Cyber Survivals

Sunday, 31 March 2013

How to Reset the Root Password for Linux

At some point we can't remember the Root password for our Linux machine. At that time we stuck in between and we have only option to  re-install linux once again. Today we will learn how to reset root password with Linux live cd.

The only thing you need is a bootable linux live cd.

you can use Ubuntu in "Try Ubuntu"mode, OpenSuse in "Recovery" mode and Backtrack5 in "Forensics" mode. Other live cd  will be fine but it has to be the same architecture (x86 or x64) as your installed system.

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

# fdisk -l

Step2: Once you found the correct partition you have to mount it and have to bind the dev environment

# Sudo mount  /dev/sda1  /mnt

#sudo mount  --bind  /dev/  /mnt/dev

Step3: After that you have to change your root directory from live environment to the installed system.
 # sudo chroot  /mnt 

Step 4: Now you can work in your installed environment and easily set a new root password.

# sudo passwd 12345

Step 5: Finally exit chroot mode and reboot system.

#exit
#sudo reboot

You should now be able to log in as root using the new password 


No comments:

Post a Comment