Are you running KDE or GNOME?
If I have got you right you want to lock an unwanted visitor out of your system without going through a hassle of Log Out/Log In process.
If so and you are a KDE user (don't know GNOME) - please read on:
For a KDE user:
1. got to K Menu > and select Control Center
PROCEED IF YOU HAVE NO PASSWORD FOR YOUR IDENTITY (usualy on linux you should), ELSE SKIP STEPS 2 to 5
2. once there select "Security & Privacy" tab
3. select "Password & User Account"
4. click "Change Password..." button at the bottom and follow the instructions there
NOW THAT YOU HAVE A PASSWORD PROTECTION FORR YOUR IDENTITY:
5. click "Apply" button in the right-bottom corner, then "Back" button (it's in the top-left corner)
6. click "Appearance & Themes"
7. click "Screen Saver" tab
8. make sure the check boxes "Start automatically" and "Require password after stop" are checked; also adjust the delays (the numbers on "Auto" lines) according to your preferences.
9. click "Apply" button in the right-bottom corner, then click "Back" button
10. click "Regional & Accessibility"
11. click "Keyboard Shortcuts"
12. Now, for the next and final step we will need "pause/break" function button of your actual physical keyboard; it's usually located in the top-right corner, next to the "scroll lock" button. (please make sure this button isn't already in use. to do so please press the button and wait for a while - if there was no effect it isn't in use and we can preceded)
13. in the "Keyboard Shortcuts" tab make sure you are on "Shortcut Schemes" sub-tab and "Global Shortcuts" sub-sub-tab
14. Enter a word "Lock" in the "Search" line at the top of "Global Shortcuts" sub-sub-tab
15. Only one "Action" should become visible in the table under: "Lock Session" it is.
16. Click on that ("Lock Session") entry.
17. At the bottom of the window, under the table where actions are listed there is a "Shortcut for Selected Action" area. In that area click upon a square shape that looks like a button.
18. A new window called "Configure Shortcut" is now visible. In this window there are two entries: "Primary Shortcut" and "Alternate Shortcut"
19. Click on "X" button located to the right of "Primary Shortcut" label - a square on the right should become empty now. Once it does press "Pause" button on your physical keyboard.
A "Configure Shortcut" window should now close automatically and a square shape that looks like a button should now have a word Pause written on it.
20. click "Apply" button in the right-bottom corner.
21. Close Control Center.
From now on, whenever you have to leave your room, all you have to do is press "Pause" button on your keyboard and your computer will be locked automatically. Later, once back, all you have to do is enter your password to unlock the computer.
Hope this helps.
(wish I could provide some pictures to illustrate the process, but I have nowhere to host them