A virtual terminal or virtual console is a feature of Unix based system that allows multiple users to access the system resources simultaneously. It is a full-screen terminal that doesn’t run inside an X windows system. A mouse can’t be used inside a virtual terminal.
On a desktop with a broken Xserver (graphical environment), the virtual terminal provides a terminal session from which the Xserver can be reconfigured. To perform tasks such as copy and paste some text on the prompt you need to use shortcuts. Ahead in this article, we will discuss more a virtual terminal or console.
History and the concept of virtual terminal
In earlier days when the personal computers were so expensive companies prefer to use mainframe computers. A device called terminal, which is generally a monitor with an integrated keyboard is used to connect to the mainframe computer on the serial port. Since this terminal exists physically it is known as a physical terminal. Once it gets connected, a user can start using system resources by using that terminal. A mainframe computer can have multiple terminals connected to its ports so multiple users can use it at a time. The earliest terminals were also called teletypes or TTY.
A similar concept still exists in Unix based systems which allows multiple users to log in on a system and use it simultaneously. These terminals are implemented with the operating systems in the form of code. So these are known as virtual terminals.
Starting a virtual terminal
The number of virtual terminals varies from distribution to distribution in Linux. For instance, Ubuntu has 6 virtual terminals i.e. TTY 1 to 6. You can access these terminals by using the combination of ctrl+alt+ F1 to F6. For example to use TTY1 you need to follow the below steps –
1.Press ctrl+alt+F1 to launch tty1
2. Now enter your username and password and press enter to log in.
If your system has no x session(GUI) then you need not use the Ctrl key. Simply use it as alt+F1 to F6.
Navigating through virtual terminals
You can switch from one terminal to another by using ctrl+alt+F1 to F6. Suppose you want to move from tty1 to tty5 simply press ctrl+alt+F5. And to get back to tty1 again press ctrl+alt+F1 this will bring you back to the virtual terminal 1. Now if you want to switch from one virtual terminal to another without using the function keys. You can do that by using
chvt command. To move from tty1 to tty3 execute the following command in your tty1 prompt-
sudo chvt N
where N is the number from 1 to 7
To move to tty3 –
sudo chvt 3
To get back to your GUI session from a virtual terminal CLI, press ctrl+alt+F7. Or enter the following command in the virtual terminal –
sudo chvt 7
Some useful virtual terminal shortcuts
The following are some important shortcuts that you can use in a virtual console.
|Ctrl+d||Logout the current user in the terminal|
|Ctrl+Alt+Del||Reboot the system|
|Tab||Use to autocomplete a command|
|Ctrl+a||Move the cursor to the start of the current line|
|Ctrl+e||Move the cursor to the end of the current line|
|Ctrl+u||Erase the current line|
|Ctrl+w||Delete the word before the cursor|
|Ctrl+k||Delete the line which is the right to the cursor|
|history||Display the history of commands executed|
|Arrow up||Scroll up in the history and press enter to execute the command|
|Arrow down||Scroll down in the history and press enter to execute the command|
That’s all for now. If you have a query or suggestion regarding the given topic feel free to write us in the comments below.