First, let's try your account from the console. WRITE DOWN THESE DIRECTIONS BEFORE BEGINNING - you won't be able to read from here once you start.
Press Ctrl-Alt-F1. This will bring you to a text only console. Log in with your username and password. Once you've accomplished that, do sudo -s
, and give it your password again. After doing that, press Press Ctrl-Alt-F7. This will bring you back to the usual graphical screen you're used to.
Were you able to log in at the shell? Were you able to successfully sudo to root (did the prompt change to root@yourmachine:~#
)?
OK. You've done this, and you cannot log in at all. So, you will need to reset the password for your username. First, try doing CtrlAltT to bring up the Terminal. Type in passwd
and hit enter. Will it allow you to change your password? If so, you should be good. If not, you'll need to boot to single user mode in order to reset your password.
If you could not change your password, let's get into Recovery Mode. Reboot the system, and at the GNU GRUB menu, press down arrow, and select (recovery mode) as shown here:
Now, drop to root shell prompt:
OK, now you'll need to remount your root filesystem read-write, and then you can change your password:
root@yourmachine:~# mount -o remount,rw /
root@yourmachine:~# passwd yourname
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@yourmachine:~# exit
NOTE: you may be confused about what your actual username is - it's not necessarily the same thing you see at the Ubuntu login prompt! For example, I see "Jim Salter" when I log into my workstation, but my actual username is something completely different and much shorter. If your system tells you there is no such user, you can do less /etc/passwd
to look for your actual account name - it should be towards the end of the file. Mine looks something like this:
myrealusername:x:1000:1000:Jim Salter,,,:/home/myrealusername:/bin/bash
Once you've successfully changed the password on your account, exit
, "resume normal boot", and log in as normal, with shiny new (working!) password.
Best Answer
You can't do that using the GUI tool, but you can using the terminal.
First, if your user has sudo privileges, you must enable its
NOPASSWD
option. Otherwise,sudo
will ask for a password even when you don't have one, and won't accept an empty password.To do so, open the sudoers configuration file with
sudo visudo
, and add the following line to the file, replacingdavid
with your username:Close the editor to apply the changes, and test the effect on sudo in a new terminal.
Delete the password for your user by running this command:
If you ever get prompted for a password, just type enter and it should work. I've tested this answer with LightDM, the lock screen,
sudo
,gksu
and it works, but there's one more step to get it to work withpkexec
(thanks muru).