Multiple consoles in linux

Why do Linux systems have multiple virtual consoles?

Why multiple consoles? Because — oddly enough — Linux started out as a terminal emulator.

As to «why 7»? That’s not inherent to the operating system; you can actually have any number of virtual consoles, within reason. It’s configurable in /etc/inittab on most distributions.

Because that’s what one did if one was a multi-user operating system on a PC Compatible.

In the world of minicomputers, one had multiple real terminals, usually attached through a terminal concentrator or some such, and multiple users could each have a terminal. In the world of the IBM PC, however, one generally didn’t have real terminals at all. It was, after all, a personal computer.

So multi-user operating systems supplied virtual consoles that were displayed on the PC’s display adapter, and that one switched between using hot-key combinations. Concurrent CP/M-86, back in 1982, had four virtual-consoles, which one switched between using the keyboard combinations Ctrl + 1 , Ctrl + 2 , Ctrl + 3 , and Ctrl + 4 .

SCO Xenix in the early 1980s had what was called Multiscreen. As a Linux user, you’ll find it very familiar. There were originally 10 virtual terminals, whose character device files were named /dev/tty01 to /dev/tty10 . One switched among them using Alt and a function key — Alt + F4 to switch to virtual console number 4, for example. One could also cycle through them in order by pressing Control + PrtSc . With the release of Xenix 5, the number of virtual consoles was increased from 10 to 12, to reflect the existence of the Enhanced PC/AT keyboard with its additional F11 and F12 function keys.

Away from the world of MP/M and Unix, the VMS-like and DOS-like world of PC Compatible operating systems had similar ideas. This was true even for non-multi-user operating systems. OS/2 version 1.0 in 1987, for example, had a Session Manager from which one could start up to 15 sessions, separate virtualized combinations of display output and keyboard/mouse input. One cycled between sessions in order with Alt + Esc and switched back to the Session Manager (from which one could start new sessions or switch to existing sessions from a menu) with Control + Esc .

MS-DOS 5 had dosshell which switched the screen between multiple programs (albeit without multitasking as OS/2 had) and had the familiar Alt + Tab and Alt + Esc . DR-DOS 6 had taskmax where one used Control + Esc to get to the Task Manager and Ctrl + 1 , Ctrl + 2 , and so forth to switch directly to the screens of individual tasks, which could be swapped to and from disc or extended/expanded memory (subject to some constraints).

By the time that Linux came around in the 1990s, the idea that what one saw on the (text mode) display and typed in at the keyboard was the virtualized input/output of just one of several sessions/tasks/terminals/consoles, that one could switch amongst with hot keys, was pretty much embedded in people’s thinking. It had been around in the PC Compatible world for almost ten years.

Читайте также:  Linux удалить символы во всех файлах

As for what use they are, I give you the words of Robin Raskin and Kaare Christian:

Xenix’s Multiscreen feature is a boon for those who like to do several things at once. A single keystroke switches the console screen and keyboard from one log-in session to another. It’s as if you have several terminals on your desk, but with only one physical screen and keyboard. The applications for this feature quickly become evident. For example, when preparing a table of figures, I used the editor on one screen and a desk calculator program on another, and I previewed the printer output on a third. Switching from one to another was trivial: Alt-F1 pulled up the editor screen, Alt-F2 brought forth the calculator, and Alt-F3 showed me the printer preview. Each screen switch takes just a fraction of a second.

— Robin Raskin and Kaare Christian (August 1986). «Xenix System V: A Multi-User Answer for the AT?». PC Magazine 5(14). ISSN 0888-8507. Ziff Davis, Inc.. pp. 253–266

Nowadays, of course, one can crank up a GUI with multiple terminal emulators and switch amongst them without switching the entire display buffer, and the display adapter barely gets a sniff of operating in its text mode. (Even then, one could do this on Unix workstations, which had graphical frame buffers and the X Window System.) So having multiple virtual consoles seems less of a feature. But to those who came from the world of multi-user computing on minicomputers with only real terminals, where clustering together a group of terminals on one’s desk was a power-user thing to do, especially if one hadn’t pulled screen from comp.sources.unix (the other power-user thing to do), it definitely was at the time.

Further reading

  • SCO Xenix System V Operating System Run-Time Environment. The Santa Cruz Operation Inc.. 1987.
  • Concurrent CP/M-86 Users Guide. Digital Research. 1982.
  • Judd Robbins (1988). Essential OS/2. Paraninfo. ISBN 9780895884787. pp. 10,92

Источник

How to Use ‘Tmux Terminal’ to Access Multiple Terminals Inside a Single Console

System administrators often need to work on multiple consoles and thus they appreciate the ability to switch from one to another in a snap with a quick keyboard shortcut or mouse click.

Tmux Manage Multiple Linux Terminals Inside Single Console

To do this, in GNOME-based desktop Linux distributions you can install a tool called Terminator, which provides an efficient way of splitting a single window into multiple terminals for different tasks.

However, there are other options that you will need to consider, specially if you’re in front of a CLI-only server or if the X Windows System has crashed in your desktop distribution. Additionally, certification programs such as the Linux Foundation Certified System administrator, the Linux Foundation Certified Engineer only provide a command line interface for their respective exams.

Читайте также:  Server печати на linux

In this article we will introduce you to tmux (short for Terminal MUltipleXer), a simple and modern alternative to the well-known GNU screen utility, and will enable you to access and control a number of terminals (or windows) from a single terminal. This tool will work both in a CLI-only environment and within a terminal emulator in a desktop distribution.

In addition, being able to create multiple tmux sessions can help you organize your work into different areas to increase your productivity.

Update: Here is another article about wemux, that improves tmux to make multi-user terminal easier and more powerful. It enables users to start a new wemux server and have other users join in either, read more about it:

Installing tmux Terminal Multiplexer in Linux

To install tmux, you can use your standard package management system.

For CentOS/RHEL/Fedora (included in the base repository):

# yum update && yum install tmux

Debian (from the admin packages section of the stable version) and derivatives:

# aptitude update && aptitude install tmux

Once you have installed tmux, let’s take a look at what it has to offer.

Getting Started with tmux Terminal Multiplexer

To start a new tmux session (a container for individual consoles being managed by tmux) named dev, type:

At the bottom of the screen you will see an indicator of the session you’re currently in:

Tmux Terminal Indicator

    1. divide the terminal into as many panes as you want with Ctrl+b+» to split horizontally and Ctrl+b+% to split vertically. Each pane will represent a separate console.
    2. move from one to another with Ctrl+b+left , +up , +right , or +down keyboard arrow, to move in the same direction.
    3. resize a pane, by holding Ctrl+b while you press one of the keyboard arrows in the direction where you want to move the boundaries of the active pane.
    4. show the current time inside the active pane by pressing Ctrl+b+t .
    5. close a pane, by placing the cursor inside the pane that you want to remove and pressing Ctrl+b+x . You will be prompted to confirm this operation.
    6. detach from the current session (thus returning to the regular terminal) by pressing Ctrl+b+d .
    7. create a new session named admin with
      1. detach from the session named admin
      2. reattach to the session named dev with

      All the examples above are illustrated in the following screencast. Please take a minute to watch it and practice before proceeding:

      Note that when there are no more panes left in a tmux session, such session is terminated.

      Changing tmux Terminal Key Bindings

      In tmux, the combination of keys used to perform a certain action is called key bindings. By default, key bindings consists of a combination of the Ctrl key and other(s) key(s), as we explained in the previous section.

      If you find the default key bindings used in the preceding examples inconvenient, you can change it and customize it on either 1) a per-user basis (by creating a file named .tmux.conf inside each user’s home directory – do not omit the leading dot in the filename) or 2) system-wide (through /etc/tmux.conf , not present by default).

      If both methods are used, the system-wide configuration is overridden by each user’s preferences.

      For example, let’s say you want to use Alt+a instead of Ctrl+b , insert the following contents in one of the files mentioned earlier as needed:

      unbind C-b set -g prefix M-a

      After saving changes and restarting tmux, you will be able to use Alt+a+» and Alt+a+t to split the window horizontally and to show the current time inside the active pane, respectively.

      The man page of tmux provides additional details and further suggestions for convenient key bindings that I’m sure you’ll find interesting to try.

      Summary

      In this article we have explained how to use tmux to divide your terminal or console window into multiple panes that you can use for different purposes.

      I hope you have found this tool useful (actually, I’d love to hear that!), feel free to drop us a line using the form below. Do the same if you have any comments, questions or suggestions about this article.

      Источник

      Multiple consoles for a single C++ application in Linux

      enter image description here

      I am working on a C++ program that can print output to more than one console. std::cout << value sends the value to console 1 (standard output) and std::cout2 << value sends the value to console 2. My OS is Linux and I am using Eclipse IDE. This post and this show how this is down for a C++ application in Windows. How can I do this for my C++ code in Linux? I have a multi-threaded application, and I want each thread to print to its own console. Clarification: Eclipse (like many other IDEs) has a console tab that shows you the standard output. Whatever you print to std::cout is shown in this console. I want to have a console2 tab so that I can selectively print to console or console2 in my C++ program.

      Likely, you ask about multiple terminal windows (that is multiple terminal emul;ators), don’t you?

      Can you clarify what it is you mean by «console»? It’s not clear from context. Do you mean the system’s console terminals that you can access by hitting keys like alt-F1 ?

      Linux (and other unix-like systems) also has multiple text consoles (on a typical Linux system they are usually accessible via , . )

      Normally the shell «owns» the process and the process’ output is displayed by the shell. But there’s only one owner to a process. What you want is having «child»-consoles too for each you can just pipe the output to. The thing is, shell doesn’t need a terminal-window to run. But in your scenario you probably want to open more terminal-windows or, if working on the tty, pipe to anothrr one. I yet don’t think that this is good practice at all. Better log to a file and use tail+grep in combination to «split» the output.

      Create multiple console tabs in eclipse: stackoverflow.com/questions/7261151/… and use them with named pipes: tldp.org/LDP/lpg/node15.html

      Источник

Оцените статью
Adblock
detector