There are some things you need to do before you sell your Mac in order to wipe your personal data off securely and reinstall OS X. You’ll want to back up your computer, sign out of your Apple accounts, erase the hard drive, and restore OS X. This video shows you the steps you should follow.
If you already have your new Mac, you can use Apple’s Migration Assistant to move your files over. However, I don’t have my new Mac yet so I’ll start with the backup.
1. Create a backup
Connect an external hard drive to your Mac (or you can use a Cloud storage solution if you have enough space available) and backup all your important data such as photos, music, videos, documents, etc.
2. Sign out of Apple services
Open iTunes. From the menu bar at the top of your computer screen, choose Store, Deauthorize This Computer. When prompted, enter your Apple ID and password. Then click Deauthorize. While still in iTunes go to Store, Sign Out. Next sign out of iCloud. If you use Find My Mac or other iCloud features on your Mac, you should first archive or make copies of your iCloud data. After that, choose Apple Menu, System Preferences, click iCloud, and then deselect the Find My Mac checkbox. In System Preferences, click iCloud, and then click the Sign Out button. When you sign out of iCloud, you’re asked whether you want to remove iCloud data from your Mac. Your iCloud data will remain on any other devices that are using the same Apple ID. If you’re using OS X Mountain Lion or later, sign out of iMessage by going to the Messages app, choose Preferences, Accounts. Select your iMessage account, then click Sign Out.
3. Erase your Mac hard drive and reinstall OS X
If you’re transferring your Mac to a new owner, you might want to erase your built-in startup disk before reinstalling OS X. Before you erase and reinstall, make sure you have backed up your important files. If you’re using a MacBook, MacBook Air, or MacBook Pro, make sure the power adapter is connected and plugged in while performing these steps.
You can use these steps to erase the files on your startup disk and install a new copy of OS X:
Before you begin, make sure your Mac is connected to the Internet.
Restart your Mac. Immediately hold down the Command and R keys after you hear the startup sound to start up in OS X Recovery.
When the Recovery window appears, select Disk Utility then click Continue.
Select the indented volume name of your startup disk from the left side of the Disk Utility window, then click the Erase tab.
If you want to securely erase the drive, click Security Options. Select an erase method, then click OK.
From the Format pop-up menu, select Mac OS Extended (Journaled). Type a name for your disk, then click Erase.
After the drive is erased, close the Disk Utility window.
If you’re not connected to the Internet, choose a network from the Wi-Fi menu.
Select the option to Reinstall OS X.
Click Continue and follow the onscreen instructions to reinstall OS X.
After you reformat your hard drive and reinstall OS X, the computer restarts to a Welcome screen and asks you to choose a country or region. If you want to leave the Mac in an out-of-box state, don’t continue with the setup of your system. Instead, press Command-Q to shut down the Mac. When the new owner turns on the Mac, the Setup Assistant will guide them through the setup process.