| The ConsoleMe
page, the one about
Virtual Terminals. |
| Paragraphs
in this page are: Theory Practice |
Theory Considering command line, every terminal we see in Linux is virtual. In other words, our screen simulates one or many hardware terminals. So, in in the ttys, when we press alt F1 alt F2 etc. we circle around terminals in a single keyboard-monitor-mouse combination. Linux Distros usually boot with 6 ttys (or other virtual terminal devices) and you can change the number with ease (I reduced it to 4).
Furthermore, an application can initialize in a new terminal, leaving the rest of the others still available. So, think of ttys as Virtual Terminals in a single keyboard-monitor-mouse combination where you could initialize more than the specified ones. Q: What's a real terminal? A: A character terminal is generally a monitor and keyboard device combination that connects to a central processing unit through a serial port for example, and interacts with the characters it receives. It is dumb, meaning that it has not processing power of it's own. The days when the processing units were big as rooms, users logged in via dozens of dumb terminals. Q: Is there another terminal type? A: Yes, the X terminal. X terminals are keyboard-monitor-graphics card-network card device combinations that interact to graphics data through for example, a network cable. Allthough are not "dumb", the processing power is still centralized to one or many remote proccessing units. In both modern types, you can attach a mouse easily. Since most computers already have the hardware that an X terminal has, they can easily simulate the X terminal role. Inside a Gui, character terminals are handled like windows. We can start as many as we want, plus minimize, move, maximize, cascade them etc.
|
||||||||
Practice Handling a terminal in a Gui is not a problem to any user. We are going to learn how to operate tty terminals. 1) Operation between terminals Changing terminals: With keyboard combinations alt F1 alt F2 etc. we change to the corresponding terminal number. We can also use alt [left or right] arrow combination to go to the previous-next terminal. If logged on, we can also do this through the command line: chvt 1 chvt 2 etc. will change to corresponding tty. This command will output the tty device we are in: tty /dev/tty2 might be the answer. But if we do this via a Gui terminal like xterm: tty /dev/pts0 Remember, we are not in a tty in this case. This command initializes a new virtual terminal: openvt mc opens Midnight Commander in a new tty If the new tty is 7, then alt F7 or chvt 7 will take us there. So, the old one is free for use. If we exit mc the new virtual terminal closes. With deallocvt we free all unused resources. So, if we type openvt bash, we initialize bash in a new tty.
Operation between terminals is powerful, but individual terminals are also powerful. 2) Operating a single terminal. This paragraph applies to tty And Gui terminals We are going to use a single terminal i.e. tty 1
Q: Why is the application frozen in the backround? A: Some full screen console applications behave strangely when active in the backround. That's why an application is put in the backround initially frozen. But, if you have an application that gives simple data to the standard output like cp you can ctrl z it and then bg make it active to the background. When job done, exits safely. Please Do This If you have a real job to be done. So, remember: Do not make applications like mc active in the backround. A command like cp can be put in the background AND active this way: cp [parameters] & How to kill applications in the backround:
Scrolling the terminal When output exceeds terminal rows then only the new output is shown. In simple words, the terminal "scrolls down". How can we then see the previous output? Simply scrolling up. X terminals scroll with the methods below: scroll bar mouse wheel shift page up/page down Additionally, Kde Konsole can be scrolled with shift up/down arrow. Tty terminals can be scrolled with shift page up/page down. Freezing the terminal In Kde Konsole, previous data can be scrolled while data output is occuring at the same time. In the same occasion though, ttys and other x-terminals would return to the last position, not leaving us to "browse" the old data. There is a method to "freeze" the terminal in such a situation. Ctrl s freezes ttys, xterm & other X-terminals but not Konsole. Ctrl q reactivates them. If a working program needs to output data in a frozen terminal, it will wait till the terminal unfreezes again, to continue work. A copy operation in verbose mode (cp -v) is an example. But consider that not only common verbose output will wait for a working terminal. Warnings and errors will wait too.
|