X screen lockers are fine, but I sometimes have stuff open on other TTYs that I want to lock as well. For this reason I would like to use vlock -a to lock all TTYs at the same time. However, I am typically in an X session when I want to run this command.

vlock cannot be run from within X because it complains that the current terminal is not a virtual console. I tried to make some solution with chvt but I don't know how to run the command in that console afterwards.

How can I lock all TTYs without exiting X (preferably using vlock, but I'm open to other suggestions)?


See this command line option:

          Switch to a new virtual console before locking all console sessions.

What I always do is sudo vlock -ans, works inside / outside Xorg.

It will jump back to the original VT when you unlocked it.


Too bad, Arch Linux replaced the original vlock package with the one provided by kbd package. That one can lock only the current console, which is useless to you. (none of -a -n -s is supported, sigh)

The workaround can be tricky, you must manually install the original vlock, and mask kbd from upgrading in pacman.conf

See this link for further information

  • I do not have this option in my version of vlock (Arch Linux). Any idea how to get it? – Zhao Xi Apr 25 '14 at 5:04
  • @user66104 Too bad, check my update please – daisy Apr 25 '14 at 5:14

If your heart is not set on using vlock, you should take a look at physlock. Physlock does exactly what it seems that you are looking for: it switches to a new VT, locks it and disables console switching. Upon unlocking, you are returned to whatever console you were on when you invoked it (and it can be invoked from X or from a TTY).

It has a great set of options and remains incredibly light-weight; I actually use it for my default screenlocker in combination with xautolock.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.