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.


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  plugin


vlock common options and usage:


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

# vlock --current


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


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.


Was this answer helpful? 0 Users Found This Useful (0 Votes)