If you’ve done something silly and can’t log on with your ubuntu user (in my case it was changing my ~/.pam_environment file to something invalid, then this is worth remembering:
Log on as guest.
Press Ctrl-Alt-F1 to get terminal mode
log on as yourself and make changes to the files.
Press Ctrl-Alt-F7 to exit terminal mode