Geek Posted March 30, 2012 Posted March 30, 2012 <div class="KonaBody"><p><img src="http://osxdaily.com/wp-content/uploads/2012/03/lock-screen-mac-command-line.jpg" alt="Lock the Mac OS X Screen from the Command Line" title="lock-screen-mac-command-line" width="620" height="150" class="aligncenter size-full wp-image-28960" /></p> <p>With the help of a buried menu item, we can lock the Mac OS X screen right from the Terminal. This does not log a user out, it just brings up the standard Mac OS X <a href="http://osxdaily.com/2011/01/17/lock-screen-mac/">lock screen and login window</a>, requiring a valid user and password before the Mac can be used again. </p> <p>Open Terminal and enter the following in a single line:</p> <p><code style="font-size:92%;">/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession -suspend</code></p> <p>There isn’t any confirmation, the desktop is immediately locked and the lock screen appears regardless of what is currently going on with the active user account. </p> <p>For those wondering, the menu item being used is the same Fast User Switching menu that displays a <a href="http://osxdaily.com/2012/01/10/remove-user-name-from-menu-bar-os-x/">user name in the upper right corner</a>, and the lock screen shown is identical to what is summoned if one were to select “Login Window…” from that same menu.</p> <p>You can lock a screen using a <a href="http://osxdaily.com/2011/01/17/lock-screen-mac/">keyboard shortcut as well</a>, but using the command line offers two obvious advantages; it can be included within scripts or entered from <a href="http://osxdaily.com/2011/09/30/remote-login-ssh-server-mac-os-x/">SSH</a> to remotely lock a Mac. </p> </div> <p><a href="http://feedads.g.doubleclick.net/~a/5GUeyQ4H18klV8JB5HWJpHeAck4/0/da"><img src="http://feedads.g.doubleclick.net/~a/5GUeyQ4H18klV8JB5HWJpHeAck4/0/di" border="0" ismap="true"></img></a><br/> <a href="http://feedads.g.doubleclick.net/~a/5GUeyQ4H18klV8JB5HWJpHeAck4/1/da"><img src="http://feedads.g.doubleclick.net/~a/5GUeyQ4H18klV8JB5HWJpHeAck4/1/di" border="0" ismap="true"></img></a></p><div class="feedflare"> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=4d2-91Vdz28:51jy70SsAVg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=4d2-91Vdz28:51jy70SsAVg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/osxdaily?i=4d2-91Vdz28:51jy70SsAVg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=4d2-91Vdz28:51jy70SsAVg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/osxdaily?i=4d2-91Vdz28:51jy70SsAVg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=4d2-91Vdz28:51jy70SsAVg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=4d2-91Vdz28:51jy70SsAVg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=qj6IDK7rITs" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/osxdaily/~4/4d2-91Vdz28" height="1" width="1"/> View the full article
Recommended Posts