There's a number of reasons why you might want to hack into, or break into, a password-protected Mac computer without using the password.

The first - and we hope this doesn't apply here - is that you're an unscrupulous criminal attempting to access someone's private files. (In fact, in this article we show how to beef up your Mac security so you can ensure other people don't use these methods against you.) But a more likely reason would be that you've simply forgotten your password, or you're trying to help someone who forgot theirs.

Either way, getting past the password protection is relatively - and, one might say, worryingly - straightforward. We're going to explain three methods. The first is by far the easiest and quickest; try the others only if the first one doesn't work.

How to hack into a Mac without the password: Change the password in Recovery Mode

The easiest way to change the user or administrator password, and the one we would recommend, is to use Recovery Mode.

Restart or boot up your Mac and, while it's starting up, hold down Cmd + R. After a short wait this will boot you, without asking for a password, into Recovery Mode. Select Utilities (in the top menu bar), then Terminal. Type resetpassword, press Enter, and you'll be taken to the password reset menu. Now select the hard drive and the user whose password you wish to change, type in a new password (try to remember it this time!), add a password hint if you think this will be necessary, and hit Save.

Read next: How to reinstall Mac OS X using Recovery mode

How to hack into a Mac without the password

Apologies for the state of the screenshot. Taking screengrabs in Recovery Mode is a pain.

How to hack into a Mac without the password: Change the root password and access the keychain

Changing the user password gives you broad access to the user account, but you don't get access to the keychain; and this means that any apps or documents that were secured by additional passwords held in the keychain will be denied to you if you can't remember them. To access the password keychain you'll need to change the root password.

Where it says 'Select the user account', choose 'System Administrator (root)', and then proceed as before.

How to hack into a Mac without the password

How to hack into a Mac without the password: Reset the password in OS X Installer

You can also change the password using the OS X installer, but this is more complicated.

If you've got the installer disc for Mac OS X, load the disc into your Mac and boot up or restart; hold down C as it boots and you'll be taken to the Mac OS X installer.

(A quick note - when testing out these methods on a MacBook we occasionally found that the USB keyboard wasn't working during boot-up. It should be fine, but if you're holding down the keys to activate Recovery mode - or, in later methods, Single User Mode or whatever - and it isn't working, one quick fix to try is to use the keys on the laptop itself.)

These days, however, very few people have got or can use the installer CD for the version of OS X they're currently using - we tend to download and update OS X from the App Store, and most recent Mac models haven't even got a CD drive. In this case, things are a little more complicated.

If you've got a recovery partition set up (here's how to create a recovery partition so you're covered in future, but that won't help you now), you can hold down the Option key (also known as Alt) while booting and choose the recovery partition at startup.

If you haven't got a recovery partition, you can load the installer file for your chosen version of OS X on to a flash drive. Unless you set this up already, you'll need a second Mac that you have got the password for to get hold of the installer file. Here's how to create an emergency Mac OS X boot disk from a USB flash drive. You can then boot from that.

However you get to the Mac OS X installer, you'll now be able to change the Mac's password. If you're on OS X 10.7 Lion or earlier, select Utilities (from the menu bar), then Password Reset. You'll need to choose the drive on which OS X is installed, and the user whose password you want to change; then type in a new password and try to remember it this time. If you're on OS X 10.8 Mountain Lion or later, select Terminal, type resetpassword and hit Enter, and again you'll be able to type in a new password.

How to hack into a Mac without the password: Reset the password in Single User Mode 

If for whatever reason you can't or don't want to access the OS X installer, another option is to use Single User Mode and once again change the password you can't remember to something you can. This will involve a bit more typing.

Reset or start up the Mac and hold down Command + S while it boots to bring up Single User Mode. If you're running OS X 10.6 Snow Leopard or earlier, type the following:

/sbin/fsck -fy
/sbin/mount -uw /
launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
dscl . -passwd /Users/[username] [new password]

If you're running OS X 10.7 Lion or later, type this:

/sbin/fsck -fy
/sbin/mount -uw /
launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
dscl . -passwd /Users/[username] [new password]

In both cases, you'll need to replace [username] (including the brackets) with the user of the account whose password you want to change, and [new password] (again, including the brackets) with your new password. If, for example, your username was smithjohn and the new password you wanted was 12345678, you'd type

dscl . -passwd /Users/smithjohn 12345678

What if you don't know the username for the account? No problem - Single User Mode will happily list the home folders on the Mac, and in most cases these will match the available usernames. Type:

ls /Users

and hit Enter.

How to hack into a Mac without the password: How to stop people changing your password and hacking into your Mac

It's worrying, really, how easy it is to reset and thereby bypass the password on a Mac. But if reading this article has disturbed your peace of mind, try not to worry: there's a strategy that will help. By turning on encryption you'll prevent anyone else from using these methods on you.

(Just remember that, if you forget your password, encryption will keep you out just as effectively as anyone else. So this is a good policy for people carrying corporate laptops containing sensitive data that’s backed up on company servers, but risky for home users who wouldn’t like to be locked out of their files.)

If you're satisfied that the benefits of encryption outweigh the risks for you, open System Preferences on your Mac and select Security & Privacy. Go to the FileVault tab, click the padlock icon at the bottom left, enter your password and click Unlock, and the finally hit Turn On FileFault. When you've finished updated your security options, click the padlock again to stop other people making further changes.

How to stop someone changing your Mac password