What you can do if you're locked out of your own computer

If you've forgotten your password and can't log in, you have several paths forward depending on what kind of computer you have and what you set up when you first created the account. Windows, Mac, and Linux each handle password recovery differently, and the fastest route depends on whether you saved a recovery email, set up a backup code, or have access to another administrator account on the same machine.

The key point: you don't need to erase everything on your computer to get back in. Most recovery methods let you reset the password while keeping your files, programs, and settings intact. A full wipe is a last resort, not a first step.

Key Takeaways

  • Windows lets you reset a forgotten password using a recovery email or phone number tied to your Microsoft account, without erasing your files.
  • Mac users can reset a password using an Apple ID, a recovery key, or another administrator account on the same computer.
  • If you have physical access to the computer but no recovery method set up, you may need to boot into safe mode or use a password reset tool, depending on your operating system.
  • A full factory reset erases everything on the drive and should only be done if no other recovery method works.
  • Setting up a recovery email and backup codes right now prevents this problem from happening again.

Windows: using your Microsoft account recovery email

If your computer runs Windows 10 or Windows 11 and you set up a Microsoft account (rather than a local account), the fastest recovery method is the password reset page. Go to account.microsoft.com/security from any device with internet access, click "Security," then "Password security," and select "I forgot my password." Microsoft will send a reset link to the recovery email you provided when you created the account.

Click the link, answer a security question or verify a code sent to your phone, and create a new password. Once you've reset it online, go back to your locked computer, click "I forgot my password" on the login screen, and sign in with your new password. Your files and programs stay on the computer.

If you don't remember the recovery email address or can't access it, Microsoft offers other verification methods: you can answer security questions you set up, verify your identity using a phone number on file, or use a backup code if you saved one. The process takes a few minutes and doesn't require you to touch the computer itself.

Windows: resetting a local account password

If you created a local account (one that doesn't use a Microsoft email) instead of a Microsoft account, password recovery is harder but still possible if you set up a recovery email or phone number in Windows settings. Go to Settings > Accounts > Your info, and look for "Password recovery options." If you added an email or phone there, you can use it to reset the password the same way: go to the login screen, click "I forgot my password," and follow the prompts.

If you didn't set up a recovery method and you have another administrator account on the same computer, log in with that account. Go to Settings > Accounts > Other people, find your locked account, and click "Reset password." You won't need the old password to create a new one.

If neither of those works, you'll need to use a third-party password reset tool on a USB drive, which requires downloading the tool on a different computer first. Tools like Ophcrack or Hiren's Boot CD can reset Windows passwords, though the process is more involved and involves booting from the USB drive.

Mac: using your Apple ID

On a Mac, if you've forgotten your login password, restart the computer and hold Command + Q when you see the login screen. This opens the password reset dialog. Enter your Apple ID email and password, and you can create a new login password without erasing anything on the drive.

If that doesn't work, restart again and hold Command + Option + R to boot into Recovery Mode. Once the Mac utilities appear, go to Utilities > Reset Password, select your user account, and reset it using your Apple ID. Again, your files and programs remain untouched.

If you don't remember your Apple ID password, you can reset that at iforgot.apple.com using your recovery email or phone number. Once your Apple ID password is reset, use it to reset your Mac login password through Recovery Mode.

Mac: using another administrator account or recovery key

If you set up another administrator account on the same Mac, log in with that account. Go to System Settings > General > Users & Groups (or System Preferences > Users & Groups on older macOS versions), click the lock icon to unlock it, then select your locked account and click "Reset Password." You can create a new password without knowing the old one.

If you saved a recovery key when you first set up your Mac, you can use it instead. Restart the Mac, hold Command + Option + R, and when the Recovery Mode utilities appear, select "Reset Password." Choose your account and enter your recovery key instead of your Apple ID password.

Linux: booting into single-user or recovery mode

Linux distributions vary in how they handle password recovery, but most let you boot into single-user mode or recovery mode without needing the password. Restart the computer and hold Shift (on Ubuntu) or Escape (on other distributions) to see the boot menu. Select "Recovery mode" or "Single-user mode," then choose "Drop to root shell prompt."

Once you're in the root shell, type passwd username (replace "username" with your actual account name) and press Enter. The system will ask you to create a new password without asking for the old one. Type your new password twice and press Enter. Restart the computer normally and log in with your new password.

If you're not comfortable using the command line, some Linux desktop environments like Ubuntu also let you reset the password through the login screen itself. Click "Forgot password?" if that option appears, or restart in Recovery Mode as described above.

When you need a full factory reset

If you've tried every recovery method and none of them work — you don't have a recovery email, you don't remember your Apple ID, you don't have another administrator account, and you can't boot into safe or recovery mode — a factory reset is your last option. This erases everything on the drive and reinstalls the operating system from scratch.

On Windows, use a bootable USB drive with Windows installation media (you can create one on another computer using the Windows Media Creation Tool). Boot from the USB, choose "Repair your computer," then "Reset this PC," and select "Remove everything." On Mac, boot into Recovery Mode (Command + Option + R), go to Utilities > Disk Utility, erase the drive, then reinstall macOS. On Linux, use a bootable USB with your distribution's installer and choose to erase and reinstall.

After the reset, you'll have a blank computer with a fresh operating system. You can then set up a new account and restore your files from a backup if you have one. This is why backing up your computer regularly matters — a forgotten password becomes an inconvenience instead of a disaster.

Preventing this from happening again

Once you're back in, spend five minutes setting up recovery options so you don't get locked out again. On Windows, go to Settings > Accounts > Your info > Password security and add a recovery email and phone number. On Mac, go to System Settings > General > Users & Groups, select your account, and make sure your Apple ID is linked and your recovery key is saved somewhere safe (write it down or store it in a password manager). On Linux, write down your password in a find location or use a password manager.

Also turn on automatic backups now. Windows has File History, Mac has Time Machine, and Linux users can set up rsync or another backup tool. If your password is lost and recovery fails, a backup means you can wipe the drive and restore your files without starting from nothing.

Frequently Asked Questions

Will resetting my password delete my files?

No. Password recovery methods like using a recovery email, Apple ID, or another administrator account reset only the password, leaving all your files, programs, and settings intact. A full factory reset does erase everything, but that's a last resort only when no other method works.

Can I reset my password without the recovery email?

On Windows, you can use a phone number or security questions if you set them up. On Mac, you can use a recovery key or another administrator account. On Linux, you can boot into recovery mode. If you have none of these, a factory reset is the only option.

How long does password recovery take?

Using a recovery email or phone number usually takes a few minutes. Booting into recovery mode and resetting through the operating system takes 10 to 20 minutes. A full factory reset can take 30 minutes to an hour depending on your drive size and computer speed.

What if I don't have access to the recovery email anymore?

On Windows, you can answer security questions or verify a phone number instead. On Mac, use a recovery key or another administrator account. If you have none of these options, contact Microsoft or Apple support with proof of ownership, or perform a factory reset.

Should I use a password manager to avoid this in the future?

Yes. A password manager like Bitwarden, 1Password, or KeePass stores your passwords securely and syncs across devices. You only need to remember one strong master password. This prevents lockouts and makes it easier to use unique passwords for each account.