Hi, I have lost the root password to my Ubunbtu machine (Release 16.04.1). Is there anyway to recover it? I have access to a non admin account only right now.
You have to boot in to Recovery Mode. Reboot the machine and press down shift key until you see the GRUB menu showing different boot options. Choose recovery mode.
Now you will see recovery menu.
Choose option
root Drop to root shell prompt
You will see a root prompt.
The file system in read-only at this point. Make it writeable by command:
mount -rw -o remount /
Now you can use the passwd command to change any user's password.
For root just type passwd
root@ubuntu:~# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@ubuntu:~#
For any other user use passwd <username>
root@ubuntu:~# passwd user1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@ubuntu:~#
As long as you have physical access to the machine, you can use this method to recover password.