Running multiple Linux terminals in one window

Linux offers many ways to split a terminal window into several mini-screens, which allows for a “multitasking” mode of operation in a certain sense. This can be done in at least five different ways.


It would seem that what could be better than the warm flickering of a Linux terminal? -)
It turns out this: the warm flickering of two terminals! In fact, the more the merrier.

Terminals were once physical devices, but today they are just applications on your computer. If you are actively using the terminal, you have probably come across many times that one terminal is often not enough. And then you need to open a new terminal (new window) so that you can work in it while the first terminal is busy compiling, converting or other data processing.

If you are a system administrator, then most likely you will need several open terminals: one for managing a web server, another for managing a database, a third for copying files, and so on. When there are a lot of open tabs, it becomes difficult to track all processes at the same time, which greatly complicates the work.

Terminal applications with the ability to open multiple tabs have long existed in Linux, and, fortunately, this trend began to develop in due time. Now everyone takes a multi-tab terminal for granted. And yet, the need to switch between tabs is a nuisance for many.

Therefore, the next step is to split into screens: two or more mini-terminals can be opened simultaneously in the same window. Most Linux builds have many tools to help organize such a partition.

Linux Shells, Terminals, and Text Consoles


Before we start hacking windows along and across, I’ll remind you the difference between the shell, terminal and console:

  • — , - «» . , - (, ).
  • — , Linux (, X11 Wayland) . , . , .
  • « » « » — , , . , Alt-Ctrl-F1 (Alt-Ctrl-F2 ). .

Some applications allow you to split the shell and console into screens, while others allow you to split the terminals.

tmux



This is perhaps the most flexible tool. tmux is a terminal multiplexer, work with which is completely based on hot keys. You will never have to take your hand off the keys in search of a mouse, but you will have to study what certain key combinations do.

You can “overlay” one tab on another, and then switch between them. You can also split a tab into two (three, four, etc.) screens.

If you use tmux primarily for splitting into screens, then it will be enough for you to learn a few combinations:

  • Ctrl-B% split vertically (one screen on the left, another on the right)
  • Ctrl-B " split horizontally (one screen above, the other below)
  • Ctrl-B O switch between panels
  • Ctrl-B? open help
  • Ctrl-B d leave tmux and leave it running in the background

Tmux has many interesting features: for example, starting a tmux session on one computer and remotely connecting to the same session from another computer. For example, thanks to tmux running on Pi, I can connect to IRC from anywhere: I run tmux on Pi, and then log in from any computer that I have access to. When I log out, tmux continues to work, patiently waiting for me to connect to the session from another machine.

GNU Screen




By analogy with tmux in GNU Screen, you can connect and disconnect from an already running session and split the window into screens horizontally and vertically.

However, this tool is not as flexible as tmux. The GNU Screen Ctrl-A introductory combination is also a command to jump to the beginning of a line in Bash. Therefore, when the multiplexer is running, to go to the beginning of the line, you must press Ctrl-A two times, not one. So, personally, I usually change this combination to Ctrl-J in $ HOME / .screenrc:

escape ^jJ

Screen split function at Screen works well, but it has some shortcomings that are not present in tmux. For example, when you split a terminal window, a new copy of the terminal does not start on the panel that appears after the split. You must press Ctrl-A Tab (or Ctrl-J Tab if you redefine the keyboard shortcut like me) and create a new shell manually using Ctrl-A C.

Unlike tmux, the splitting does not disappear when you exit the terminal. which is a design feature, which in some cases is very useful. Although sometimes it is inconvenient, because it forces you to manage the reset of the partition manually.

However, GNU Screen is a reliable and powerful application that you can run if you find that tmux is unavailable to you for some reason.

Here are the basic GNU Screen commands:

  • Ctrl-A | ( — , — )
  • Ctrl-A S ( — , — )
  • Ctrl-A Tab
  • Ctrl-A ?
  • Ctrl-A d Screen ( , screen -r)

Konsole



Konsole is the standard KDE Plasma desktop terminal. Like KDE itself, Konsole has extensive customization options.

Among its many functions is the ability to split a window into screens. Since Konsole is a graphical terminal, you can control it with the mouse, not the keyboard.

To do this, go to the View menu. You can split the window horizontally or vertically. To switch the active panel, simply select the panel you need with the mouse. Each panel is a unique terminal, so it can have its own theme and tabs.

Unlike tmux and GNU Screen, you cannot disconnect and reconnect to a Konsole session. Like most graphical applications, you use Konsole while physically in front of it. Therefore, for remote access you have to use special software.

Emacs



Emacs is not a terminal multiplexer, but its interface supports window splitting and resizing. It also has an integrated terminal.

In any case, if you work daily with Emacs, this means that you have appreciated the opportunity to conveniently organize your workspace. Moreover, since the Emacs eshell module is implemented on eLISP, you can interact with it using the same commands that you use in Emacs itself, which makes it easy to copy and extract long file paths or output commands.

If you use Emacs in a graphics window, you can perform some actions with the mouse. For example, you can select the active panel by clicking on it, or resize the screens after breaking the window.

Although sometimes it’s faster to use keyboard shortcuts:

  • Ctrl-X 3 split vertically (one screen on the left, another on the right)
  • Ctrl-X 2 split horizontally (one screen above, the other below)
  • Ctrl-X O switch between panels (this can be done with the mouse)
  • Ctrl-X 0 (0 is zero) close the current panel

Similar to tmux and GNU Screen, you can disconnect and connect to an Emacs session through emacs-client .

Window manager



If you think that a text editor that can split a window into screens and launch a terminal in each of them is a mystery of nature, then what would be your surprise when it turns out that your desktop can perform the same tasks. Linux desktops such as Ratpoison, Herbsluftwm, i3, Awesome, and even the KDE Plasma desktop can be configured so that each application window appears as a fixed tile in the desktop grid.

Instead of windows floating “above” your desktop, they remain in a designated place, so you can switch from one to the other. You can open any number of terminals on your network by emulating a terminal multiplexer. In fact, you can even open the terminal multiplexer in the desktop multiplexer.

And nothing prevents you from opening Emacs inside it with its multiplexer mode. No one knows what will happen if you continue in the same vein, and most Linux users agree that it’s best not to repeat this at home.

Unlike tmux and GNU Screen, you cannot disconnect and reconnect to the “session” of your desktop without using special software.

More options?


Believe it or not, there are many more options. There are terminal emulators such as Tilix and Terminator, applications with built-in terminal components, and much more.

And how do you split your terminal into screens?



As an advertisement


VDSina offers virtual and physical servers for any task, a huge selection of operating systems for automatic installation, it is possible to install any OS from its own ISO , a convenient control panel of its own design and daily payment. And we also have eternal servers;)


All Articles