vlock is a command-line program that will lock your Linux terminal, as well as virtual consoles.

How to Install vlock on Linux

It’s easy to install vlock on your system. All you have to do is use your distro’s default package manager.

On Debian/Ubuntu:

Arch Linux users can install vlock as part of the kbd package. It’s in the “core” repository and thus installed by default. You can install the package manually if it isn’t:

As with Arch, on an RHEL-based distro like Fedora or CentOS, vlock should be installed by default. But if it isn’t, run:

Locking Your Terminal With vlock

When you’ve installed vlock, you can lock your terminal by simply calling it at the command line:

This will clear the screen and display the message, “This TTY is now locked.”

To use your terminal, press Enter and vlock will prompt you for your password. After that, you’ll be able to use your terminal as before.

The root password will also unlock the terminal if it’s enabled. This is useful if another user on the machine ran vlock and forgot their password.

Locking All Virtual Terminals on Linux

While you can lock an individual terminal, a typical Linux desktop has a number of virtual consoles that anyone can switch to if they have physical access to your machine. If you’ve locked one console, someone can launch another instance of the virtual terminal and log in that way.

Fortunately, it’s easy to lock these as well with the -a or –all flag. You’ll have to be actually logged into a virtual console to use this option or it will give an error.

This will lock all the virtual terminals on your system, so nobody will be able to log into them.

Keep Your Linux Machine Safe From Prying Eyes

Locking your terminal with vlock can keep unauthorized users from making changes on the Linux command line if you’ve stepped away from your machine.

If you actually want to be productive with the Linux terminal, Tmux is a great way to have many terminal sessions in one window or virtual console.