Updated: 29 September 2026 · Applies to: vlock 2.2 on Ubuntu 24.04 and 26.04 and Debian 13; GNU screen 4.8 and 5.0 on AlmaLinux, Rocky Linux and Fedora

When you step away from a server's text console (a physical screen, IPMI or a VPS console), anyone who sits down can use your logged-in session. vlock locks the console until you type your password again, while your programs keep running. It is packaged for Ubuntu and Debian; AlmaLinux, Rocky Linux and Fedora no longer include it, so for them this guide shows alternatives. We checked vlock 2.2.2 on Debian 13.

Install vlock (Ubuntu, Debian)

apt install vlock

Use it

vlock            # lock this console only; others can still switch to other consoles
vlock -a         # lock all virtual consoles: nobody can switch away
vlock -a -s      # lock all and also disable the SysRq key while locked

To unlock, type the password of the user who locked it; root's password also unlocks it. Be careful with -a: if you forget your password, you are locked out of the console. -a works only on a real virtual console (tty1 to tty6), not in an SSH session; -n switches to a new virtual console before locking all of them.

AlmaLinux, Rocky Linux and Fedora: lock with screen

Run your console work inside screen (on AlmaLinux and Rocky Linux it comes from EPEL: dnf install epel-release, then dnf install screen). To lock it, press Ctrl+A and then X; screen asks for your password to unlock. Your programs keep running while it is locked.

Lock automatically

To log out idle shells after 15 minutes, set a timeout for all users in /etc/profile.d/timeout.sh:

TMOUT=900
readonly TMOUT
export TMOUT

This ends idle bash sessions, on the console and over SSH. Running programs in the foreground are not affected until they return to the prompt.

Remote sessions

vlock protects the local console. For SSH sessions, lock your own computer's screen when you leave it, and use SSH keys with a passphrase.

Official documentation: vlock manual and GNU screen manual.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket