Reset password Linux

In case you ever forget the your password in Linux there are several ways you can go about resetting it if you have physical access to the machine.  On your boot up menu select the recovery mode option you should end up at a command prompt on a black screen type the following cmd

#passwd username

Remember to change out ‘username’ with your real username. You will be prompted to enter the password twice, when done just restart your machine and you should be able to log in with your new password, if the cmd completed successfully . This method works in some Linux distributions but not all of them.

Another option is to boot up from Live CD, open up a command prompt and mount your HD as root/super user or with sudo whichever applies. Chroot your mounted drive then use the passwd cmd to change password as below.

$su

#mount  /dev/hda1 /mnt/hda1

#chroot /mnt/hda1

#passwd username

You will be prompted to enter the password twice when done just restart your machine and you should be able to log in with your new password

NB: To reset root password with the above methods just run the passwd command without including a username.