There are different ways to lock your screen.
Note: These shortcut tips are for Sierra and below. In High Sierra, there is a new entry under the Apple Menu (with shortcut) to lock the screen.
1. Use keychain
Open keychain -> Settings. Choose from there Show keychain status in menu bar.
You can now choose from the menu bar to lock your screen.
With this option, you need your password to log in next time.
2. Use Hot Corners to lock your screen
First, go to your System Settings -> Desktop & Screen Saver and choose Hot Corners on the bottom right.
Next, choose one of the corners the option Put Display to Sleep. I prefer bottom right, but this is by each user different.
That's all. One note: You can configure in the Privacy Settings when the display will be locked. For example, if you have it set to five minutes, you need to enter your password after the time in your setting is gone. You can change this to immediately, for example.
3. Lock Screen (with Shortcut)
Because @Flimm asked for a shortcut to lock the screen, here is a solution below High Sierra.
Usually, there are two solutions. You can use CTRL+Shift+Power Button or
CTRL+Shift+Eject-Key to lock the screen.
Both solutions are not my favourites, and for that reason, I've created a Shell Script with Automator. Thanks to Taylor who gave me this hint.
- Open Spotlight and type Automator to open the Application.
- Create a new Document.
- Choose Service to make as global Service.
- On the left Pane, choose Utilities; and on the right column, double-click Run Shell Script. You see a Window with the Cat-Command.
- Delete the cat-Command and copy & paste the following Shell-Script into the empty Window:
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
Make sure that on the top right of the Automator-Window, both pull down-menus are set as no input in any application.
- Click on the top right to the Run-Button (marked with green circle) and test if it works.
- Save your workflow now as Lock Screen, for example.
- Open System Preferences, Keyboard and click on the Button Shortcuts or Keyboard Shortcuts.
- Choose on the Left columns Services and search for your saved workflow.
- Add your favourite Shortcut (e.g. I have Cmd + Alt/Opt + L).
For better understanding, I have put the pictures below.
Apple Support Documents Mac Keyboard Shortcuts