It’s easy to reset a lost administrative password in Ubuntu, but the process to do so isn’t exactly intuitive. Ubuntu, and the various other Canonical Ltd.-recognized derivatives like Xubuntu and Ubuntu Kylin, hash out the root account and default to the first user’s account acting as an administrative one. Therefore you won’t be able to guess the root password, and will have to reset your machine to change the first user account’s password.
You’ll first need to reboot your machine, and then push the left shift key. Timing for hitting this key can be a bit tricky, so sometimes its necessary to restart a couple of times. When you get it correctly, you should receive a GRUB screen, where you can select different options.
Changing a Lost Administrative Password
When you’re at the GRUB menu, hit the down arrow on the keyboard until you’ve selected the second entry down, which should read something like “Ubuntu, with Linux x.xx.x-xx-generic (recovery mode) where the Xs would be filled with the version of the Linux kernel you’re running at the moment.
Push the enter key, and you’ll see a “Recovery Menu” box. Scroll down to “Drop to root shell prompt” with the down arrow and push enter. You have a read-only filesystem, so remount it with mount -rw -o remount / and push enter again. Type passwd followed by whatever your user name is and push enter.
You’ll be prompted to set a new UNIX password. Type it, push enter and then type it again. It should tell you that it has been updated successfully, after which you can reboot and now use your new password fine.