Increasing the Number of GUI and Virtual Terminals(CLI) in Linux and Navigating Between Them
Part 1: Increasing CLI VirtualTerminals
Introduction: In Linux, virtual terminals (VTs) provide a text-based interface for users to interact with the system. By default, Linux systems offer a limited number of virtual terminals, but in certain situations, increasing the count becomes necessary. This technical blog will guide you through the process of increasing the number of virtual terminals using /etc/systemd/logind.conf
and how to navigate between different virtual terminals using the tty
, chvt
, and keyboard shortcuts.
Prerequisites:
Basic understanding of Linux terminal commands and configuration files.
Access to a Linux system with administrative privileges.
Step-by-Step Guide:
Step 1: Understanding Virtual Terminals (VTs) in Linux: Virtual terminals are text-based interfaces accessible through the Ctrl
+ Alt
+ F1
to F6
key combinations. By default, most Linux distributions provide six virtual terminals. These terminals can be used to perform various tasks simultaneously.
Step 2: Modifying logind.conf File: To increase the number of virtual terminals, edit the /etc/systemd/logind.conf
file using a text editor with administrative privileges:
$ sudo vi /etc/systemd/logind.conf
Step 4: Updating the Number of Virtual Terminals: In the logind.conf file, uncomment the line starting with #NAutoVTs=
and specify the desired number of virtual terminals. For instance, to increase the number of VTs to 10, use:
NAutoVTs=10
Step 5: Saving and Exiting the File: Save the logind.conf file and exit the text editor.
Step 6: Restarting systemd-logind Service: To apply the changes, restart the systemd-logind service:
$ sudo systemctl restart systemd-logind
Step 7: Navigating Between Virtual Terminals: To move between different virtual terminals, use the following methods:
Using Keyboard Shortcuts:
Press
Ctrl
+Alt
+F1
to switch to VT1 (default terminal).Press
Ctrl
+Alt
+F2
to switch to VT2 and so on, up to VT7.
Using
tty
Command: Thetty
command displays the file name of the terminal connected to the standard input. For example, to determine the current virtual terminal, use:$ tty
Using
chvt
Command: Thechvt
command switches to a specified virtual terminal. For instance, to move to VT3, use:$ chvt 3
Part 2:Increasing the Number of GUI in Linux and Understanding the Transition from inittab to systemd Targets
Introduction: Graphical User Interfaces (GUIs) provide a visual way to interact with the Linux system, offering a more user-friendly experience. In earlier versions of Linux, the /etc/inittab
file played a crucial role in managing system runlevels, including GUI startup. However, with the introduction of systemd
, traditional runlevels were replaced by targets. In this continuation of the technical blog, we will explore how targets replaced runlevels, how the two main targets (multi-user.target
and graphical.target
) are related, and how to increase the number of GUI sessions using the startx
command.
Understanding the Transition from Inittab to systemd Targets:
Step 1: The Role of /etc/inittab: In earlier versions of Linux, the /etc/inittab
file served as the configuration file for the init process, responsible for system initialization and management of runlevels. Runlevels determined the system's state, with runlevel 3
indicating a multi-user, non-GUI environment, and runlevel 5
indicating a graphical environment.
Step 2: Introduction of systemd and Targets: With the adoption of systemd
, a system and service manager, runlevels were replaced by "targets." systemd
uses targets to represent predefined system states. The two main targets are:
multi-user.target
: Analogous to the previousrunlevel 3
, this target represents a multi-user, non-GUI environment.graphical.target
: Analogous to the previousrunlevel 5
, this target represents a graphical environment with a GUI.
Step 3: Viewing and Setting the Default Target: To view the current default target in systemd
, use the following command:
$ systemctl get-default
To set a new default target, use:
$ sudo systemctl set-default TARGET.target
Here, replace TARGET.target
with the desired target name (multi-user.target
or graphical.target
).
Increasing the Number of GUI Sessions using the startx
Command:
Step 1: Understanding startx
: The startx
command is used to start a GUI session on a Linux system. It launches the X Window System, which manages the graphical environment, and a user's preferred desktop environment or window manager.
Step 2: Checking the Number of Available GUI Sessions: To check the number of available GUI sessions, first, switch to a virtual terminal with a non-GUI environment using Ctrl
+ Alt
+ F1
. Then, run the following command to view the number of active GUI sessions:
$ w
The output will display information about the logged-in users and the active sessions, including GUI sessions.
Step 3: Starting Additional GUI Sessions with startx
: To start an additional GUI session, switch to a virtual terminal (e.g., Ctrl
+ Alt
+ F2
) and log in with a different user or the same user. Then, run the startx
command:
$ startx
This command will start a new GUI session for the current user. If you logged in with a different user, it will launch a separate GUI session for that user.
Step 4: Navigating Between GUI Sessions: To switch between GUI sessions, use the Ctrl
+ Alt
+ F7
key combination to return to the default GUI environment. Use Ctrl
+ Alt
+ F8
, F9
, and so on, to access other GUI sessions.
Conclusion:
In this combined blog, we explored two essential aspects of Linux system management: increasing the number of virtual terminals and understanding the transition from /etc/inittab
to systemd
targets for GUI startup.
With the introduction of systemd
, traditional runlevels were replaced by "targets." The multi-user.target
represents a non-GUI environment, while the graphical.target
represents a GUI environment. We learned how to modify the /etc/systemd/logind.conf
file and use sudo systemctl restart systemd-logind
to increase the number of virtual terminals.
Additionally, we discovered the startx
command to initiate GUI sessions and navigate between them using virtual terminals. These improvements in system management offer enhanced flexibility and productivity for users.
Overall, these steps empower users to customize their Linux experience, manage GUI environments effectively, and maintain system integrity. However, it is essential to exercise caution when modifying system files and resources to ensure a smooth and stable user experience.