You just have to reformat your hard drive and reinstall a clean version of the operating system.
The first thing you should do before hitting the streets to sell your old Mac is clear it of any and all personal data. You don't want to accidentally sell your computer to a stranger when you are still logged into iCloud.
1. Back up
If you already have your new Mac on hand, you can transfer all of your data from your old Mac or use an older Time Machine backup. If you don’t have your new Mac, just make sure to back up your data before you get what you need on the your new Mac
2. Sign out
The software you have on yours is licensed to you, which means it doesn't get transferred to the new owner of your computer. In order to avoid complications with the new owner attempting to download and install software that is licensed by you, make sure to sign out of everything your personal information is connected to.
3. Reformat your hard drive
- Restart your Mac.
- Hold down Command and R at the same time right after you restart your Mac. Keep holding down the keys until your Mac finishes loading and you see the macOS Utilities window.
- Select Disk Utility.
- Click on Continue.
- Select your Startup disk
- Click on Erase from the buttons at the top of the Disk Utility window.
- Select Mac OS Extended from the drop-down menu next to Format.
- Select GUID Partition Map from the drop-down menu next to Scheme
- Click Erase