Locking the PC while going for a coffee break, Lunch or toilet is longly used to secure physically your PC display from spying eyes or prevent you from someone to install a spying software or leak private data from PC HDD to an USB drive.
People who are coming from the wonderful MS Windows OS are certainly used to quick shortcut key combination to lock PC screen with:
Windows key + L
So how to do Lock Screen on Linux?
On Linux locking your Screen the Quick Shortcut is:
CTRL + ALT + L.
Locking the screen is done (depending on the Linux distribution) by using by either using historically famous XScreenSaver if non-gnome / KDE graphical environemnt is used or if in Linux Gnome GUI with gnome-screensaver and on KDE desktop manager with kscreenlocker.
Exact command executed on CTRL + ALT + L keypress on GNOME is:
On KDE to manually lock screen command is:
Nomatter whether with GNOME or KDE its worthy mention that xscreensaver is more Screensaver rich than kscreenlocker and gnome-screensaver as it includes about 200 different Screensavers making screen nice to watch when you come back from a lunch.
For people with Windows key keyboard who are too used to using Windows XP / 7 lockreen WIN + L key shortcut to make Windows (key) + L keys combination work on Linux with GNOME desktop:
System -> Preferences -> Keyboard Shortcuts
Make Win + L keys combination work on Linux with KDE desktop
- "System Settings" (KDE menu).
- Choose "Keyboard & mouse" (on "General" tab).
- Choose "Global Keyboard Shortcuts" on the left.
- Choose "Run Command Interface" from "KDE component" dropdown list.
- Choose "Lock session".
- Select "Custom".
- Click on "None" (button changes to "Input…").
- Compose your desired sequence by pressing appropriate buttons on your keyboard.
- Click "Apply".
For other desktop environments like Window Maker you can use xmodmap command to bind Win + L keys