Let me guess… you lost your password? ehh , don’t worry the net is full of different solutions to the matter of this possible problem. First let me start by saying that this tutorial is not intended to retrive your original password (see my Cryptography section for that). Also if you have an encrypted home directory (like with TrueCrypt) this method won’t work.
There are several ways to reset your password. I will describe here 2 methods:
Method # 1 – No live cd
Method # 2 – With live cd
Name-codes used in this tutorial:
USERNAME = your username (ex. john, abby,..)
PASSWORD = your password (ex. pAsSwRd123)
PARTITION = your partition name (ex. sda1, sdb2, hda3,..)
Let’s get started!
———–Method # 1 – NO live cd————-
1- Start up the computer and at the grub menu select Recovery mode
If you do not see the grub menu press “SHIFT” key at boot time.
2- From the recovery menu select ROOT console
3- At the prompt type:
root@tHOSTNAME:~#mount -o rw,remount /
Changing password for USERNAME.
Enter new UNIX PASSWORD:
Retype new UNIX PASSWORD:
passwd:password updated succesfully
———–Method #2 – WITH live cd————-
1- Boot the computer from an USB or CD ubuntu image. At the boot screen select “Try out”UBUNTU”
2- After the desktop session has loaded start the terminal or just press CTRL+ALT+t
3- At the terminal type:
(now here is the hard part; you have to figure out what is the partition you need to use in the next comand, usually it's the one that hase the "*" on the line, check my screen shoot for help)
mount /dev/PARTITION /mnt/new
mount -o rw,remount /
———–Method #3 – EDIT /etc/shadow FILE ————-
Let’s say you you don’t want to use the previous methods, anothe way to reset you password is to access and edit directly the shadow file of your filesystem located in /etc/shadow. I will not explain here how to mount the partition, what kind of priviledges you should have etc.. because there are multiple ways to access the linux partition, from a MacOSX, Windows, another linux distribution and so on.. but instead I will focus on how to edit the hash file properly in order to give you access to your user’s login.
here we go:
1- navigate into the /etc folder . There are sever files here, using a text editor open the one named “shadow”.
2- find the line containing your username. It should be something like this:
what is this?
= hash method (SHA512)
= hashed password
3- change these line into this :
4- save and reboot the linux system. Login with your username and at the request to enter a password simply press enter (leave it empty).
Note this methode may not work on all distributions. I noticed that Ubuntu work only with the empty method (::) where instead other ditros may accept also (:!:) and (:NP:) inputs. They all say the same thing, which is that the user does not have a password.