Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

OSX machines have a keyboard shortcut to put the machine to sleep, which suspends processing, downloads, and other operations.

OSX machines also have a Lock function which can be triggered via a menu option. It can also be triggered by running a specific command: /System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend

How can I lock my OSX machine with a keyboard shortcut?

share|improve this question
    
I have previously set up an Automator "service" to run the above command in a bash script triggered by a specific shortcut, but that no longer seems to work. Choosing the Service from the (Application) menu does nothing. Issuing the command directly works. – Eric Jul 15 '13 at 13:43

The default is:

Ctrl+Shift+Eject

Note: If you have a newer mac without a disc drive, replace Eject with the Power button.

The screen locks and turns off, but the computer is still running.

share|improve this answer
    
I believed that the shortcut you posted caused the machine to sleep, but that doesn't seem to be the case--processing does seem to continue in the background. – Eric Jul 15 '13 at 14:53
1  
Yeah, it puts the display to sleep and locks it (assuming you have that option set up). – nerdwaller Jul 15 '13 at 14:57

You can assign a shortcut to CGSession -suspend with an application like Alfred or FastScripts.

If you have the Alfred Powerpack, you can assign a shortcut for the lock action:

Or you can use control-shift-eject (or control-shift-power) if you enable this setting from the Security & Privacy preference pane:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .