[Update 1] Anyone who uses Windows at work is probably familiar with the old Ctrl-Alt-Del <return> trick to quickly lock your screen when you step away from your computer. This displays a “This computer is in use and has been locked.” message which instructs you to press Ctrl-Alt-Del again to unlock the computer. Doing so presents you with a username/password prompt, which looks very much like the login screen.
In Mac OS X, the closest thing we have is the “Require password to wake this computer from sleep or screen saver” check box in the Security system preference pane (in Mac OS X 10.5 Leopard). Then what a lot of people do is set a screen corner to activate the screen saver (via the Exposé system preference pane). Then just before they walk away, they move the mouse into the designated corner, wait for the screensaver to kick in, then walk away.
If you have OS X’s Fast User Switching enabled (via the Accounts system preference pane), there’s a second way to lock your screen which is a bit more like the Windows method. By selecting the “Login Window…” option from the Fast User Switching (FUS) menu in the top-right corner of your screen, you are taken back to the login screen while your user session continues to run in the background.
While the Mac OS X solutions works fine, some of us regular Windows users just prefer a more direct method of locking the screen similar to what is offered in Windows. I was one of those people. I liked the Fast User Switching method for locking my screen, but didn’t want to have to enable FUS to get it because I’m the only person who uses my Mac, and I didn’t want to give up the extra menu bar real estate to the FUS menu. In addition, the FUS method requires two clicks, which is one too many clicks! Ideally I wanted a single click solution or one which can be quickly activated with a hotkey.
In my searching, I found a Terminal command on MacOSXHints (it’s been posted so many times in different hints and comments too numerous to give credit to individually) which activates the “Login Window…” function from the FUS menu, even if FUS isn’t enabled! The command is as follows:
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
“Now we’re getting somewhere”, I thought to myself upon finding that little gem. If I could turn that into a double-clickable script or application, I could add it to the Dock and could lock my system with a single click of the mouse. Even better, using keyboard automation software like Spark or similar, you could even map a keyboard shortcut that would launch the script or app with the press of a couple of keys.
So to cut an already long story short, I figured out how to create a shell script and using XCode bundled it as an application. I won’t go into details on exactly how I did either, mainly because I did it a long time ago, and frankly can’t exactly remember, and that wasn’t the point of this post. Not being an artist, I borrowed Apple’s icon from Mac OS X’s Security Preference pane (thanks Apple!) and made it the icon for my new application bundle which I called simply “Lock System”. You can download the Lock System application from the link at the end of this article.
Once you’ve downloaded and extracted the zip file. Just move the Lock System application to your Applications folder (or anywhere else you want to keep it). I keep mine in ~/Library/Scripts so I can access it via the AppleScript menu. Then add it to your Dock or put an Alias on your Desktop for quick access. Finally, create a keyboard shortcut in Spark (or similar) for launching Lock System (I like Command+Shift+L), and that’s it! You can now lock your Mac like you do on Windows. Enjoy!
Lock System should be compatible with Mac OS X 10.3, 10.4 and 10.5. Anyone out there who can confirm if it still works in Mac OS X 10.6 Snow Leopard, please post your results in the comments, thanks! [Edit: See my update at the end of the article. - madgunde] This software is presented as is and with no guarantees. You use it at your own risk, so don’t be coming back to me to complain that it’s hosed your system (which would be hard to believe anyway). I’ve been using it for years now and am only sharing because I thought others might appreciate it.

Download Lock System (12KB .zip)
Update 1 – 9/8/2009, 9:30 pm: If you’re running Mac OS X 10.6 Snow Leopard, there’s an even more elegant solution that doesn’t require any third party software to accomplish the same task. If you’re not running Snow Leopard, you better have a darn good reason, like your Mac doesn’t have an Intel processor or something.
You should have told me, I’ve been doing this for months
And just a side note about Windows… Windows Key + L will lock your screen (or bring you to the fast user switching login menu)
You’ve been doing what for months? Using this hint or doing it the old way? I’ve been using this little app for a couple years now, just thought to post about it because I saw a discussion about the topic somewhere else and it dawned on me how many people don’t know about it and who might be looking for an elegant solution.
Windows + L? That’s awesome! That’s two fewer keys I have to press! Now I just have to develop the muscle memory to hit it quickly. Let’s face it, to anyone who’s used Windows for years, Ctrl-Alt-Del and Enter feel so natural we can hit them blindfolded!
Thanks for your comment!
All I can say is “great” and “finally”. I have wanted something like this for years (it’s one of my pet-peeves with Mac OS X). I will give it a try tonight.
Guess I should have posted this a long time ago then. Looks like I wrote it back in June 2004, so I’ve been sitting on this little gem for 5 years. In fact, from the creation date, it’s 5th birthday is coming up on the 30th.
Wow, has it been that long? Guess I created it while I was still on Mac OS X 10.3 Panther when Fast User Switching was new. Damn, time does fly…
Thanks sooo much!! I so hope that 10.6 will fix this with a Win+L type of shortcut! But since this is a long missing feature of OSx all i can say is i really love ur simple and 1 click-able solution!
Great job
I have tried it with Snow Leopard and it works. However, when I lock my screen it seems as if it disconnects me from the internet as well. Therefore, if I just want to lock my screen and keep a program downloading something or iChat connected to still receive IM’s it does not work. Is there a way to fix this?
Hi Hugo,
In iChat Preferences, make sure on the General tab, set “When fast user switching…” to either “Set my status to Away” or “Do nothing”.
If you’re using a PPPoE connection for your internet access, make sure in System Preferences–>Network–>PPPoE–>Advanced–>PPP that all of the following are UNchecked:
• Prompt every X minutes to maintain connection
• Disconnect if idle for X minutes
• Disconnect when user logs out
• Disconnect when switching user accounts
Also probably not a bad idea to enable (check) the following:
• Connect automatically when needed
If using an AirPort (WiFi) connection, under System Preferences–>Network–>AirPort–>Advanced–>AirPort, UNcheck the following:
• Disconnect when user logs out
If you’re using some other network connection, look through the Network pref pane for your connection for any similar options to the above and disable them. That should solve your problem.
Let us know what works for you!
Alright… very nice. That worked. I made sure to test that I indeed still had an internet connection by running a download while I used Lock System and the download kept going even while locked. Thank you.
Another easy way to do lock osx is to drag /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine onto your dock. When you click it the screensaver will activate. I find this a bit easier than a hot-corner with a multi screen setup.
This is the most miss keyboard shortcut from windoz, now who else dare to say SL cannot lock screen? Haha…
Madgunde thanks and keep up the good work!!