Ubuntu 12.04 – How to Lock Your Screen / Computer

These instructions are for Ubuntu 12.04 running the Unity interface. They may be the same for other version combinations, but no guarantee is made.

Sometimes you have to leave your computer but don’t want to leave your session open for someone else to start using.

One option is to log out, the other is to lock your session. Logging out is rather drastic and requires you to save all your work. Locking the screen allows all your work to remain as is until you unlock the screen.

Keyboard Shortcut

1) Press Ctrl + Alt + L to lock your screen.

NOTE: pressing Ctrl + Alt + L means: simultaneously hold down the Ctrl key and Alt key, then press the L key as though you intend to type it.

DO NOT press the Shift key because Ctrl + Alt + Shift + L is different from Ctrl + Alt + L.

It does NOT matter if your Caps Lock key is on or off.

Your screen should change to something like the following (your choice of desktop background, username, etc, will affect the specific appearance):

Using the Mouse

1) Click on the System icon in the top right corner of the screen:

2) Select Lock Screen from the drop down menu.

6 Comments

  • Andrew says:

    What do I do if this doesn’t work? Since I upgraded from 11.10, I can’t lock my screen any more.

    • admin says:

      Interesting question, I have not experienced this problem – so it is hard for me to offer an answer if I can’t reproduce the problem.
      I do have some guesses though. One possibility is that GNOME 3 (the window manager beneath Unity) is looking for the keyboard shortcuts in a different location than GNOME 2 (the previous window manager) was.
      Unfortunately, when you click on the System Icon (little gear) in the top right corner, it will show that Lock Screen is mapped to Ctrl+Alt+L. I think this is a bug – the displayed shortcut seems to be hardcoded into the menu instead of being dynamically read from some configuration file (I could be wrong, but this is what I have observed the past few minutes testing scenarios for your issue).
      Next, you can check to see what shows up in System Settings->Keyboard->Shortcuts->System for Lock Screen. The easiest way to access the Keyboard configuration is to type keyboard into Dash and select the app.
      Select the Shortcuts tab. Then select System from the list int eh left hand side.
      If it shows Lock Screen is mapped to Ctrl+Alt+L, then I would suggest mapping it to a different shortcut – say Ctrl+Alt+Shift+L.
      Close the keyboard app and try out the new shortcut.
      If it works, then I would open the keyboard app, remap the shortcut back to Ctrl+Alt+L and close the keyboard app and try it again.
      If it works this time, it means that the upgrade from 11.10 -> 12.04 somehow missed your keyboard shortcut settings.
      This is one of the problems I find with Linux, settings are stored all over the place and it is not always obvious which ones you are using. It could be (I am guessing) that at some point you had installed a different window manager in 11.10 to replace Unity and it had its own place to store keyboard shortcuts. When you upgraded to 12.04, it didn’t pick up those shortcuts.
      Let me know how things work out because I am curious.
      Thanks for your question.

  • Lumpy Gravy says:

    The menu item doesn’t work either. It’s not a keyboard shortcut problem, it just doesn’t do anything when you select “lock screen”.

    • admin says:

      This is one of those annoying problems because “it works on my computer”.
      This site, suggests the problem is that gnome-screensaver is not installed.
      When I uninstalled gnome-screensaver I was able to reproduce your problem (although, there may be other reasons why locking the screen does not work).
      To install gnome-screensaver either:
      (1) enter it into the Ubuntu Software Center search field and select to install it or
      (2) enter the command sudo apt-get install gnome-screensaver in a terminal.
      I’ll be honest, I do not find it the least bit intuitive that a screensaver should be responsible for locking the desktop.
      Please let me know if this fixes your problem (and thanks for the comment).

  • Lumpy Gravy says:

    Yes, thanks for this tip – installing the gnome screen saver fixes the problem with the lock screen command – it works now.
    As a work-around, I had created a user called “Lock Screen” and then selected that from the user switching menu. A real hack, but it worked until I realized you had solved my problem with your comment. Thanks again – my regular Lock Screen works again – Yay!

    • admin says:

      Awesome! I am glad it worked. Of course, it begs the question, “why does the screen saver get uninstalled in some cases?”
      An inventive hack, but … I wish Linux worked better sometimes and didn’t always need little hacks and tricks to get it to do what you want.