23.12. Linux Virtual ConsolesYour Linux workstation display may look like just one terminal. It's actually seven terminals -- or even more -- in one. Linux has built-in virtual consoles, a series of ttys (Section 2.7) that you can log into separately: each one can have a login session, with its own shell, working at the same time as the others. You can see only one of these consoles at once; you bring a console into view by pressing a hot-key combination. For instance, I log into the first virtual console as root and the second as myself. 23.12.1. What Are They?If your Linux system comes up after a reboot with a mostly blank screen something like this: Red Hat Linux release 6.2 (Zoot) Kernel 2.2.14-5.0 on an i686 penguin login: you're seeing one of the virtual consoles -- in this case, it's the first one you've seen since the reboot, so it has to be console number 1. On the other hand, if your system boots to an X Window display with a graphical xdm or gdm login box, you're using a different virtual console, probably console number 7. All of this is configurable. But by default, consoles 1 through 6 are ttys, with getty (Section 24.2) processes running, ready to manage individual login sessions. Virtual console 7 is an X Window System display. To switch between the consoles -- to bring a differnt console "to the front" -- use the hot-key combination CTRL-ALT-n, where n is the console number. (Actually, the only time you need the CTRL key is when the X Window console is in front. When you've got a nongraphical console in front, you can switch with just ALT-n. But if you find the difference hard to remember, there's no problem with always using the CTRL key.) Here's one of the reasons I like to start my window system by typing a command (startx) at a shell prompt in a virtual console. The X server, and client applications running under X, will spit error messages onto the standard output (or standard error) at the console where I ran startx. So it's easy for me to jump back to the console -- by pressing CTRL-ALT-2 -- to see error messages. Then I can jump back to X with CTRL-ALT-7. (I actually changed this setup, later, to log X errors to a file that I watch from a window, but that's another story.) When you log out of one of the tty-type consoles (by typing exit or logout), the getty process there prints a new login: prompt. But not every one of these ttys needs a login session. For instance, while the Red Hat Linux installation program is working, it uses the first four virtual consoles as logs that show different information about the installation process -- and the fifth has a shell prompt where you can do work during the installation. Another handy example is this tip from Chris Hilts, posted to www.oreilly.com as a followup to a Linux feature in the summer of 2000. Add the following line to your /etc/syslog.conf file: *.* /dev/tty9 After the next reboot or restart of syslog, all of your system's syslog messages will appear on virtual console number 9 -- where you can see them at any time by pressing CTRL-ALT-9. 23.12.2. Scrolling, Using a MouseThe tty-type virtual consoles have some other nice features. One is a scrolling buffer that lets you scroll back to see previous screens of text. Press SHIFT-PAGE UP to move to previous screenfuls, and SHIFT-PAGE DOWN to move toward the most recent screen. The tty-type consoles also support copy-and-paste with your mouse. To copy an area, point to the first character and hold down the first mouse button; move to the end of the text block and release the button. The selected text should be shown in reverse video. To paste the copied text, click the third mouse button. You also can paste from one console into another with the same steps. You can't paste from a tty-type console into the X Windows, or vice-versa, though. To do that, use a temporary file. For example, highlight (copy) an area of text, then use the command: cat > Section 12.2 % cat > /tmp/paste-me ...paste the text... CTRL-d Then switch to the other console. Either read the file directly into an application, or output the file onto the screen (cat /tmp/paste-me) and copy from that redisplayed text. -- JP Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|