Security is a major issue while you work in a company atmosphere. It is always good to lock your screen while you walk away from your MAC. It is good to protect your material if you are woking on a sensitive material or opened a valuable back account on your screen. Please read this article which describes a couple of ways to Lock Your MAC Screen
Most of these methods to work, you need to require a password when your Mac wakes from sleep or screensaver mode. First step is to set a password for your MAC.
Open System Preferences > Security & Privacy > General > select Require password for sleep and screen saver. Now you can select immediate or set some ideal time to lock your mac.
Method 1: This is the simple method. Please hit the key combination when you walk away from your system, it will do a fast logout.
Shift + Command + Option + Q
The down side of this method is that all of your currently open documents will close, and any running applications will quit prior to the logout.
Method 2: Go to Apple menu on left top of screen and select sleep.
Method 3: Another quick method is activate your screen saver using hot corner.
Open System Preferences > Desktop & Screen Saver > Screen Saver > Hot Corners > Select a Corner, then click the corresponding pop-up menu and select Start Screen Saver.
When you walk away, just fling your mouse into that corner of the screen, or Swipe your finger on track pad to that corner, and you’ll trigger the screen saver.
Method 4: This method is directly bringing your login window, without actually logging out. You have to click on Top right corner of the screen and see the icon of logged in user. Click on that name or icon and select Login Window.
Method 5: You can also lock the screen by typing
/System/Library/CoreServices/”Menu Extras”/User.menu/Contents/Resources/CGSession -suspend
into the terminal. This method is great, because it works even if you don’t require a password to exit the screensaver or wake from sleep.