Linux, Linux, and Linux. The operating system for power users. Don’t agree with me? What about the terminals? When hackers in movies are seemingly spamming their keyboard to appear as if they had hacked the whole world, what is the medium where they appear to do so? It’s the terminal, and it is very much a Linux one. Though the ones seen on films are not actually anything but work of motion graphics, Linux is actually home to most hacker kids you might find out there. The terminal power is something a professional user would prefer over clicking buttons with a mouse.
Linux is an old lad, so it has features that descend from its ancestors, particularly the so-called UNIX. One of those many features that are barely heard of by casual users is the Virtual Terminals, also known as TTY. Now I can dig deep enough to have you spend reading this article all day long, which is not my objective (at least for now). I’m here to tell ya guys about what really happens if you press Ctrl + Alt + F1, while you’re chilling in your graphical, Desktop Environment. Beware, it’s going to get so wrong if you don’t really know what you’re doing, so it’s best you hear my out first.
What happens if I press Ctrl + Alt + F1?
Nothing, at least in newer versions of Linux. If you’re using an old version, and your Linux system has a Desktop Environment, then pressing Ctrl + Alt + F1 would’ve brought you to a Virtual Terminal. Previously, there were a total of 7 virtual terminals that you could’ve used, of which there were 6 command-line (terminal) only ones, and the 7th one was assigned for the GUI, or the Desktop Environment which you usually run. You wouldn’t be able to use the first 6 virtual terminals to start separate sessions of the Desktop Environment.
But now, things have changed. Recent versions of Linux only have 6 virtual terminals in total, but there are good sides to this. Firstly, you can run 6 separate sessions running full-blown GUI Environments, as compared to only one in previous versions. However, this is mostly relevant if you use a Window Manager instead of a Desktop Environment. For now, what matters is that in recent versions, pressing Ctrl + Alt + F1 won’t do anything, as the GUI is started on the first virtual terminal instead of the 7th one. Hold on hold on hold on! I know it might be going over your head, but the following sections should give you a better idea of what I’m really talking about here. Visit this part once again after reading the next sections, if you did not understand a thing.
What are Virtual Terminals?
The main culprit here is the Virtual Terminal, which is also known as TTY. So what does it actually do? Now I can be explaining it in a tougher way using professional terms, but it wouldn’t help you understand its true objective. If I were to tell you in plain, simple English, TTYs exist because back in the day, there was nothing like Graphical User Interfaces. There weren’t window managing systems which would allow you to run concurrent programs together, neither were there these mice we have nowadays. The only way one could achieve multitasking inside his Linux machine was to use the TTY terminals, as long as the terminal multiplexers had not shown their faces yet. Linux still keeps this feature, and for a big reason. There are people who actually use only the terminal for all their computing marvels, such as Server Administrators looking all day at their terminals.
The first virtual terminal is the one where your GUI will start when you login, if it’s a recent version. If you’re using an older kernel of Linux, the GUi will start on the 7th Virtual terminal.
Each Virtual terminal is assigned from F1 to the F6 key based on the number of virtual terminal it is:
TTY 1 (1st virtual terminal) → Ctrl + Alt + F1
TTY 2 → Ctrl + Alt + F2
TTY 3 → Ctrl + Alt + F3
TTY 4 → Ctrl + Alt + F4
TTY 5 → Ctrl + Alt + F5
TTY 6 (Last virtual terminal)→ Ctrl + Alt + F6
You can also use all of the virtual terminals together, if you wish.
Now let’s say that your version of Linux is old, and the GUI has started on the 7th TTY. Now, if you press Ctrl + Alt + F1, then you should be presented with something that looks similar to the below image:
There are a few key aspects to notice in the above image. Firstly, you might not be presented with the Welcome message on top, based on your system. On the second line, the last text states “/dev/tty1“, which basically means that you have landed on the 1st TTY terminal on your system. On the last line, you should be prompted to login, and in place of the localhost text, you’d see the hostname of your our own machine.
Why would I need Virtual Terminals?
Before you start digging all into the wonders of not seeming the fruits of a Graphical user Interface, there are important use cases where virtual terminals could be your hero. Sometimes, it is possible that you run into some issues in your desktop environment, and you’re unable to run any programs, not close or start anything. In such cases, starting a virtual terminal could allow you to take control of the issue and resolve it quite easily if you know how.
Navigating between Virtual Terminals?
As of now in current versions of Linux, if you press Ctrl + Alt + F2 instead of F1 while you’re running a desktop environment, you’ll be presented to the Second Virtual Terminal in your system, which’ll prompt you to login to your user. Once logged in, you’ll be able to run any terminal commands you usually run, in a terminal emulator. But what you need to know is how to navigate between all the different virtual terminals that you can use.
When starting a virtual terminal from a GUI, you’d want to press Ctrl + Alt + F2, as the first virtual terminal is already assigned to handle the GUI. Now, login to a user and try running a command, and let it keep running. While you’re doing so, press Ctrl + Alt + F3 to start the 3rd virtual terminal, where you’ll be prompted to login once again. Keep note that you can use the same user everytime. Try running another command here and leave it as is.
The next thing you’d want to do is to press Alt + Left Arrow Key on your keyboard. You should be able to see that you’re presented the Second Virtual terminal where you had left out on a command you ran. To get back to the third virtual terminal once again, press Alt + Right Arrow key. This way, you’ll be able to navigate between all the virtual terminals starting from TTY1 all the way to TTY6.
There’s one more way to jump directly from one virtual terminal to the other, instead of pressing these key sequences many times. Let’s say you’re on the 2nd virtual terminal, and you want to go to the 6th virtual terminal. That way, you’d need to press Alt + Right Arrow a total of 4 times to get to that. Instead, you can press only Alt + F6 to directly go to the 6th virtual terminal. Notice that this time, we didn’t need to press Ctrl. This is because it is only needed when you’re shifting from a GUI to the Virtual Terminal.
How do I return to my desktop?
If you’re currently in the third virtual terminal, and if you press Alt + Left Arrow key twice, you should be able to return back to your desktop session. But that is not the only way to access your desktop, however. You can now press Ctrl + Alt + F1 instead to return to the first virtual terminal, which in turn will get you to the desktop session you were running.
Furthermore, you won’t actually need to press Ctrl this time around either. You can directly press Alt + F1 to come back to the desktop. This is because you’re doing this from a virtual terminal. If you had come to the virtual terminal from the GUI instead, you’d need to press the Ctrl key.
The elaboration of the use of Ctrl + Alt + F1 should’ve now helped you understand its use, and how you can use it yourself. We didn’t use the Ctrl + Alt + F1 for much other than returning to the GUI from a separate virtual terminal, as the newer Linux kernels start the GUI in the first terminal by default. If you were to use an older version, you could’ve probably used Ctrl + Alt + F1 to enter the first virtual terminal as well. But that way, you’d not get the ability to run separate desktop sessions at the same time, mostly if you’re using a Window Manager, which is quite crucial for a lot of power users in Linux.