Lock your screen using command line

Hi friends,
I read one article today and that was fantastic.I am sharing that article here hope you all like it.

Lock your Screen using command line in Fedora 10 and Ubuntu.

This command is extraordinary for who work on terminal continuously and want to step away for some movements.

gnome-screensaver-command –lock

NOTE –In this command, where you see “–lock”, it is really 2 hyphens with no spaces in between, followed by “lock” …  – – lock. WordPress renders two hyphens put together as… –

When you execute above command then it will activate your screen saver and prompt for password to login.But as i metioned that command is pretty long so you need to create alias for that.To create alias Follow below method.

Open your .bashrc file into your favorite editor i am using vim as my editor.before editing file dont forget to make backup.
vim .bashrc (if you are not at home directory prompt then vim /home/<user-name>/.bashrc)

Now just move to end of file and paste below content.
alias lock=’gnome-screensaver-command –lock’

Save & Exit from File.

Now above commands tells your ubuntu or fedora that if you type in lock ,it actually executes gnome-screensaver-command –lock

Enjoy Lock Screen from Command Prompt 🙂

source :- http://howto-ubuntu.com/2008/12/11/how-to-lock-your-screen-from-the-command-line/

9 thoughts on “Lock your screen using command line”

  1. This is SWEET!

    I have been wanting to put a “lock screen” icon on my desktop (in Ubuntu) for a while now as I change systems via a KVM frequently while I work – and returning to Ubuntu from another KVM port always leaves the mouse doing weird things.

    Now all I have to do is click the icon (launcher!) and I’m done!

    BTW the default launcher icon is totally lame, so I changed it to the “gnome encrypted locked” icon (a padlock) which works perfectly.

    Thanks! This is totally awesome!

    Jim (JR)

  2. Which Distribution you are using? If you are using Fedora then install xlock package by following yum -y install xlockmore* and execute xlock command to lock your root screen. I hope its available for Ubuntu also. But I didnt tried this in ubuntu

    Enjoy. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *