Running Multiple Programs in Virtual Terminals

When you log into a text-mode console, you're using a virtual terminal. To understand virtual terminals, remember that Linux was designed as a clone of Unix, which is a multiuser OS. Traditionally, Unix systems have supported dozens, hundreds, or even thousands of users, each working from a physical terminal—a device consisting of a keyboard, a monitor, and perhaps a mouse—that enables a user to access a computer remotely. You can use terminals with Linux, but a standard IA-32 PC has one primary keyboard and monitor. In order to improve usability, Linux supports configuring the system so that these devices can act like several physical terminals—that is, they're virtual. Each virtual terminal can run a separate program, or even support logins under different usernames. This feature enables you to run many programs and easily switch between them.

Most standard installations define six virtual text-mode terminals, reached by pressing Alt+F1 through Alt+F6. These terminals are defined in the /etc/inittab configuration file, using lines like the following:

1:2345:respawn:/sbin/mingetty ttyl 2:2345:respawn:/sbin/mingetty tty2 3:2345:respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty4 5:2345:respawn:/sbin/mingetty tty5 6:2345:respawn:/sbin/mingetty tty6

These lines tell the system to run mingetty on tty 1 through tty6—that is, the first six virtual terminals. The mingetty program is one of several programs known collectively as getty programs. These programs manage the interactions between a terminal (either real or virtual) and the login program, which accepts user logins. Several getty programs are available, and different distributions favor different gettys. Mandrake, Red Hat, and SuSE use mingetty; Debian uses the original getty; and Slackware uses agetty, for instance.

Note When you run X, it starts up in the first unused virtual terminal—typically, number 7. Therefore, to switch to X from text mode, you can press Alt+F7, assuming X is running. To switch from X to a text-mode terminal, you must add Ctrl to the key sequence, as in Ctrl+Alt+F1 to switch to the first text-mode terminal.

You can make effective use of virtual terminals by logging into several and running a different program in each. For instance, you might examine a man page in one virtual terminal and type commands based on what you read in another.

Team LIB

1 previous

Team LIB

^ previous

0 0

Post a comment