Saturday, September 12, 2009

How To Change Root Password Of A Linux OS If You Have Forgotton It

Someone can say that "Root is the god of the system", where it bears the literal meaning regarding the root user of a Linux system. Because he has the full access to each and every corner of the system and can change or modify it as he wishes. As a matter of fact, if the root user does something wrong with what he is doing, the system may stop working.

Anyway, if you have forgotten the root password, what can you do? It will make the system less operative since you need the root password to configure and change lot of things in a Linux System.

Assuming that you have access to BIOS, there is a possibility to change the password using a Linux Live CD.

Stuff Needed:
  1. Change the first boot device to the CD Drive or to the DVD drive. You can do this from the "Boot Settings" menu under the "Boot Sequence" sub menu. These entries change according to the BIOS system you have and the above is in general.
  2. A live CD or DVD of Ubuntu, Fedora, Linux Mint, etc (For this explanation Linux Mint Live CD has been used)
Method:
  1. After changing the first boot device put the live CD or DVD in the drive and boot up the computer.

  2. Now when it is finished loading the desktop, right click on the desktop and from the menu select "Open in Terminal". In the terminal you get, you have to give all the commands as shown and explained in the following figures. (Every command is without quotes)
  3. "sudo fdisk -l" From this you can identify the disk partition in which you have installed Linux. In this case it is /dev/sda2.

     
      
  4.  Now create a new folder using the command, "sudo mkdir /media/temp". Then you will get a folder named temp in /media.
      
  5. Now what you have to do is to mount the partition at temp folder. Use the command, "sudo mount /dev/sda2 /media/temp"
  6. Then you have to tell the system to identify this partition as the root partition. Use the command, "sudo chroot /media/temp"
  7. Now it's the final stage, where you have to change the password to a password you prefer. To do this, as in the figure, type "passwd root". It will ask you two times for the password and put the same password correctly. When it's done you will see the message "passwd: Password updated successfully".

Now restart the machine and when it comes to the login prompt, use the password you put just now. Using this method, one can change not only the root password but also the password of any existing user.

No comments: