vlock – A Smart Way to Lock User Virtual Console or Terminal in Linux

Virtual consoles are very important features of Linux, and they provide a system user a shell prompt to use the system in a non-graphical setup which you can only use on the physical machine but not remotely.

A user can use several virtual console sessions at the same time just by switching form one virtual console to another.

vlock Lock User Terminal in Linux

vlock Lock User Console or Terminal in Linux

In this how to guide, we shall look at how to lock user virtual console or terminal console in Linux systems using vlock program.

What is vlock?

vlock is a utility used to lock one or several user virtual console sessions. vlock is important on a multi user system, it allows users to lock their own sessions while other users can still use the same system via other virtual consoles. Where necessary, the entire console can be locked down and also switching virtual console disabled.

vlock primarily works for console sessions and also has support for locking non-console sessions but this has not been tested fully.

Installing vlock in Linux

To install vlock program on your respective Linux systems, use:

# yum install vlock           [On RHEL / CentOS / Fedora]
$ sudo apt-get install vlock  [On Ubuntu / Debian / Mint]

How to use vlock in Linux

There are few options that you can use with vlock and the general syntax is:

# vlock option
# vlock option plugin
# vlock option -t <timeout> plugin

vlock common options and usage:

1. To lock current virtual console or terminal session of user, run the following command:

# vlock --current
Lock User Terminal Session in Linux

Lock User Terminal Session in Linux

The options -c or --current, means lock the current session and it is the default behavior when you run vlock.

2. To lock all your virtual console sessions and also disable virtual console switching, run the command below:

# vlock --all
Lock All Linux Terminal Sessions

Lock All Linux Terminal Sessions

The options -a or --all, when used, it locks all user’s console sessions and also disables virtual console switching.

These other options can only work when vlock was compiled with plugin support and they include:

3. The options -n or --new, when invoked, it means switch to a new virtual console before user’s console sessions are locked.

# vlock --new

4. The options -s or --disable-sysrq, it disables the SysRq mechanism while virtual consoles are locked by a user and works only when -a or --all is invoked.

# vlock -sa

5. The options -t or --timeout <time_in_seconds>, invoked to set a timeout for screensaver plugin.

# vlock --timeout 5

You can use -h or --help and -v or --version to view help messages and version respectively.

We shall leave it at that and also know that you can include a ~/.vlockrc file which is read by vlock program during system startup and add the environmental variables that you can check in the manaul entry page, especially users of Debian based distros.

To find out more or add any information which may not be included here, simply drop a message below in the comment section.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.