From the official Ubuntu LostPassword documentation (with minor changes to work on more recent versions of Ubuntu)
- Reboot your computer.
- Hold Shift during boot to start GRUB menu.
- Press e to edit.
- Find the line starting with “linux” and change “ro” to “rw” then append “init=/bin/bash” at the end of that line.
- Press Ctrl + X to boot.
- Type in passwd username.
- Type the new password
- Restart and login with the new password
Tested on Ubuntu 16.04 Desktop, 64-bit