This could be very useful to you if you’re working in the terminal and need to step away for a moment. You can achieve a locked screen, just like when you do it the graphical way, with this command entered at the command line, or cli…
gnome-screensaver-command --lock
This will instantly launch your screensaver, and lock your computer’s screen. Your password will be required to gain access to your system once this is activated.
That command is pretty long, and typing it out would probably get on my nerves. You can use an alias to effectively shorten it. Here’s how we’ll do that, also at the command line…
Let’s say we want to be able to type in lock, to lock the screen. If I just type in lock, I get nothing. So I need to create an alias for this command. An alias is just like what it sounds like. It’s assigning another name to a certain command. At the command line enter…
gedit .bashrc
There’s a certain section of this file that talks about aliases. You can add this line of text to that section of the file…
alias lock='gnome-screensaver-command --lock'
This tells Ubuntu that when you type in lock, it executes gnome-screensaver-command –lock. Click the Save button and close the text editor. The next time you login, the change will have taken effect. Try it out and see how you like it.
Here’s what it should look like…

Or Ctrl+Alt+L
Or, you could just press Ctrl+Alt+L…
Well… this only works if you have X running….
also, there is no point in making an alias, you can tab-complete the command
I think (?) xlock is still there somewhere, too
What if you are running kde?
And if you want to lock a command line (ex: a virtual console), you can do it with vlock.
>> ScottLij
>>January 14, 2009 at 9:32 pm
>>Or Ctrl+Alt+L
Really great …..
you could also make a shell script
Thanks for the great ideas guys, I knew about Ctrl+Alt+L, but was exploring other options with this post.
I use slock http://www.suckless.org/programs/slock.html and have assigned a keyboard shortcut to it. Its the best screen locker, as it does only what a screen locker should, nothing more, and doesnt even need GNOME. In Debian or Ubuntu, i think you can find it in dwm-tools package.
package xlockmore
xlock -mode blank [-lockdelay 2]
lockdelay for testing…
better not have gnome-screensaver running
on background (or what)
also, check ‘man xset’ how to set various
dpms settings — I can not check those now…
I do:
$ exit
The difference is only I need to enter my username.
On wordpress you could enclose what you want to appear not rendered in
and. and everything should appear fine.command --optionmeh… i just press right CTRL and L.
easier.
love this site tho.
as for the KDE users. This is “howto-ubuntu.com” not howto-kubuntu.
Still should be easy enough.