If You Can't Log In To OS X After Restoring From A Time Machine Backup...

The explanation here works on OS X versions prior to Mountain Lion. If you have Mountain Lion reboot by holding cmd+r instead of cmd+s to go into Recovery Mode and change your password using the Graphical User Interface.

This has happened to me twice since I started taking Time Machine backups. Something went horribly wrong, you want to restore from a Time Machine backup and after all those hours of waiting for everything to be transferred over you're presented with the login screen...

But you can't log in. You type your password 3 times to make sure it's right but it doesn't let you log in. Here's how to fix it:

  1. Reboot the Mac and hold down cmd+s -- This will boot into single user mode. Black screen, white text.
  2. Mount the hard drive as explained at the prompt. -- Most likely: mount -uw /
  3. Type: passwd [your user name] -- For example: passwd jeroen (jeroen is my username on the machine). If you don't know your username, type: ls /Users
    This will list the usernames on your computer.
  4. Enter your password, and confirm it by entering it again. Notice you do not "see" what you type, this is normal.
  5. Type: exit

The machine will reboot and you'll be able to log in again. *phew*