28

For example, in X session, I can use Ctrl-Alt-L to lock the screen, so it would ask for password to unlock and prevent somebody from messing with mine computer.

But if I have an open terminal session on one of the tty's (which I can access with Ctrl-Alt-F1, for example) - then it is not locked, and somebody can still use it to do some harm. Is there a way to 'lock' that command line (with some background processes running in it, maybe)?

26

vlock will do as you ask. However, if you want to run background processes, consider screen instead, which will let you also log off and keep processes running in the background, and then reattach -- even when logged in from alternate places.

  • can't get vlock with plugins, it installs without new.so, thus I can't use vlock -na – Sergius May 6 '16 at 6:50
  • Use vlock -a to lock all virtual terminals (otherwise one could easily switch to a different terminal that might have a user logged in) – friederbluemle Dec 12 '17 at 7:53
  • 1
    @friederbluemle It's worth noting, though, that alt-sysrq-k (alt-printscr-k, of the magic sysrq family) will, depending on configuration, kill the current terminal and vlock with it, allowing somebody to subsequently switch terminals. – Erhannis Feb 8 at 4:36
9

If you run screen in the terminal, you can lock the terminal with the command Ctrl-a x.

  • 1
    It is also possible to lock a screen session automatically after becoming idle. Just specify idle 900 lockscreen in your .screenrc to lock the session after being idle for 900 seconds (15 minutes). – scai Jul 30 '13 at 7:35
  • 2
    Be careful with screen locks: they do not lock the session but only your particular window into it. Anybody else who can attach to that session with their own window to it will not be locked out. – Curt J. Sampson Jun 20 '17 at 5:53
0

Check out "binarix". It will lock your Terminal. No need for X or screen.

http://raffi.at/view/code/binarix

0

I couldn't get vlock to work un osx, so I created a simple shellscript alternative.

https://github.com/acornejo/bashlock

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.