Ask Different is a question and answer site for power users of Apple hardware and software. 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

Is there an easy way to lock my mac and then immediately sleep, all in one command? I know I can show the login window and then choose the sleep button, but I'd prefer one step rather than two (and a wait in between). There's also the Lock Screen command in the Keychain menu, but that (stupidly) offers no sleep button that I can see. Could a script work for this, or would the script also get stuck after one command?

Update: Forgot to mention that I don't want to always have to enter my password after waking up from sleep, only after I explicitly lock the computer.

share|improve this question
Locking implies password entry, what would be the benefit from locking otherwise? – patrix May 7 '12 at 8:50
@patrix: Daniel L. updated my question, hopefully it's clearer now. – newenglander May 7 '12 at 11:15
What was wrong with the question? It's always nice to get a comment when getting a downvote, otherwise how can you learn from your mistakes? – newenglander May 9 '12 at 9:01

+ + will put the computer to sleep. Then, if you have "Require password [immediately] after sleep or screen saver begins" checked under System Preferences ➔ Security ➔ General, it will prompt you for a password when it wakes up.

share|improve this answer
Forgot to mention I don't want to enter my password after every wakeup from sleep, I'll update my post. – newenglander May 7 '12 at 8:15
@newenglander In that case, don't check the "Require password [immediately] after sleep or screen saver begins" - the first part of your question also explicitly states you want to "lock my mac" – binarybob May 7 '12 at 8:28
Sorry for the confusion, Daniel L. was kind enough to update my question, hopefully now it's clearer. – newenglander May 7 '12 at 11:15
The third key in that shortcut renders as unprintable for me in Chrome, for some reason. What is it supposed to be? – Dan J May 8 '12 at 20:42
@DanJ It's the eject key. Odd though, I'm using Chrome 18.0.1025.168 and Lion 10.7.3 and it looks fine here. – binarybob May 8 '12 at 21:10
up vote 2 down vote accepted

Actually, a script containing these two commands (first one sleeps, second one suspends computer) worked fine:

osascript -e 'tell application "Finder" to sleep'
/System/Library/CoreServices/Menu\ Extras/ -suspend 

The order is apparently not important, neither command stops the other from completing.

Sorry for not making myself clear enough (Sometimes I want to put the computer to sleep without password prompt when waking).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.