Sometimes you have sensitive information on your Mac you don't want other folks to see. Or maybe you don't want someone else jumping on and using your machine when you're not looking. Whatever the case, the solution to keeping your Mac safe when you leave it unattended is to lock it with a password.
Fortunately, setting up a password lock on your Mac is easy. To do so, select System Preferences from the Apple menu, then navigate to Security & Privacy > General. Check "Require password after sleep or screen saver begins." You'll want to make it so your Mac locks on command, so set the drop-down menu to "immediately." You can also set your password here.
Now that you have that set, your Mac will be locked any time it goes to sleep, and it'll require your password to make it useable again. Of course, you can make it go to sleep by choosing Sleep from the Apple menu, or you can use a keyboard shortcut: hit Control + Shift + Eject (or Control + Shift + Power) to make the screen go to sleep, or Command + Option + Eject (or Command + Option + Power) to make the entire computer go to sleep.
You can activate an additional shortcut by going to Desktop & Screen Saver > Screen Saver. Click the "Hot Corners..." button, then set any corner of your choosing to "Put Display to Sleep" (preferably a corner you won't activate accidentally). Whenever you move your mouse to that corner, it will put the monitor to sleep, thus locking your computer. Now your data is safe and secure, even when you need to step away.
- How is iOS 9 stacking up?