home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Unix Power ToolsUnix Power ToolsSearch this book

23.12. Linux Virtual Consoles

Your 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.

Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.