Unless you store all your old Macs, replacing a Mac requires you to work out what to do with the old one.
There are three main options:
- give away
- scrap and recycle.
At one time, old computers were considered valuable to ship out to Third World Countries, and re-use was a realistic prospect. There are still a few organisations who might be interested in this, but they are now very picky over which models they will accept. If you cannot find someone to re-use your Mac, then you must arrange for it to go to scrap for recycling. Again there are some organisations who can help there, and all retailers should be able to assist.
The first step for any of these is to de-authorise all apps and iTunes accounts. At the very least you should open iTunes and de-authorise all iTunes content from that Mac. If you forget to do so, one of your five Mac ‘slots’ will remain taken up, and you could end up having to de-authorise all Macs in order to clear this in the future. Similar rules apply to apps such as Adobe CS and CC, if they are installed and authorised.
Then make sure that everything of any importance on the Mac’s drive(s) is backed up to at least two different locations, so that you can at any time go back and retrieve copies of material which was stored on it.
If you use iCloud for storage or services, you may want to back up any iCloud content too, and should then sign out of iCloud on that Mac. When you do that, you will be asked if you want to remove iCloud data from the Mac, which you should agree to. Those files will still be kept on other Macs and devices which share the same iCloud account afterwards.
If you have and use iMessage, start the Messages app up, open its Preferences, and in the Accounts section sign out of that account. No further messages will then come to that Mac.
You then need to erase your hard drive(s) and perform a fresh install of your current version of OS X. With Mavericks or later, you will need it connected to the Internet to do this. Apple advises that you should do this in a way that does not associate the Mac with your Apple ID. The best way to achieve that is to start up in remote Recovery mode, with the Command, Option, and R keys held down. In versions of macOS from 10.12.4 onwards, this will install the latest compatible version of macOS; in El Capitan and earlier, it will install the closest version to the original which was first installed on that Mac. There seems to be no way to dissociate those older Macs from your Apple ID and to install a more recent version of macOS. When in Recovery mode, select Disk Utility, select your startup drive, and click on the Erase tab.
In almost all cases (the exception being when your Mac has not stored sensitive or personal information and is going to a close friend or near relative), you should then click on the Erase Free Space button, and select the level of security to use. The more secure the cleaning, the longer it will take, but the more difficult it would be for anyone to recover any information from your drive. Then select Mac OS Extended (Journaled) for the format, enter a name for the volume, and click on the Erase button.
Once the startup drive has been erased and initialised, quit Disk Utility and – only if your Mac is going to be reused – select Reinstall OS X, then the Continue button.
Follow the instructions during the reinstallation, but when your Mac restarts and invites you to select the country or region, press Command-Q to shut it down. When its new owner starts it up, they will then see the Welcome screen as if it was a new Mac, and be able to configure it for themselves. If you are running in remote Recovery mode, it will no longer be associated with your Apple ID or account.
If your Mac is going for scrap and recycling, do not waste time reinstalling OS X once the startup drive has been erased. Simply shut it down, and disconnect it from the mains power supply. It is in your interest then to open it up, remove the hard drive, and do as much damage as you can to it using a sledgehammer or similar. That should prevent anyone else from being able to recover anything from the drive. Then make sure that all traces of you and your information are removed.
(Updated 16 May 2017 to reflect changes in reinstall with 10.12.4.)